Wednesday, June 26, 2013

Using VIRTUAL Column in JPA Entity


While working with Java Persistence using ORM Layer, new feature from Oralce 11g can be useful.
E.g. Virtual Column.
 
Whenever want to use Virtual Column in JPA Entity, it should follow:
  • Field should not be Updatable.
  • Field should not be populated while creating the entity.

For such scenario, one has to use below annotation on field:
@Column(insertable=false, updatable=false)

Below is Detailed Example JPA Entity with Virtual Column usage:

Virtual Column Should be added like:
alter table cosnumers add(
     IS_ADMIN GENERATED ALWAYS AS ( CASE WHEN CONSUMER_ID IS NOT NULL THEN 1 ELSE 0 END)
);

JPA Entity Should define field for Virtual Column as shown below:
Package com.acp.jpa;

import javax.persistence.Column;
import javax.persistence.Entity;

@Entity
public class Consumer {

       private Long consumerID;

       @Column(insertable=false, updatable=false)
       private boolean isAdmin;
      
       /**
       * @return the consumerID
       */
       public Long getConsumerID() {
              return consumerID;
       }

       /**
       * @param consumerID the consumerID to set
       */
       public void setConsumerID(Long consumerID) {
              this.consumerID = consumerID;
       }

       //--- For Virtual Column - Provide only Getters.
       /**
       * @return the isAdmin
       */
       public boolean isAdmin() {
              return isAdmin;
       }

}



--
III  Cheers!

Thursday, June 20, 2013

Using Oracle SQL Developer as MySQL IDE

Need to follow below steps:

- Download desired MySQL connector, unzip and place to desired directory.
- From SQLDeveloper -> Tools -> Preferences -> Databases -> Third party JDBC driver.
  "Add Entry" for desired MySQL connector.

That's It!!!

Now you can observe MySQL tab in the DB Connections SQLDeveloper window.


References:
http://www.techrepublic.com/blog/programming-and-development/configuring-sql-developer-for-mysql/564


Cheers!

Thursday, June 13, 2013

Eclipse Performance Enhancement!

Hi,

Most of the time we suffer from Eclipse responsiveness or performance.

Below is the link for changing Eclipse Memory settings in "eclipse.ini" file: