Posts

Showing posts with the label oracle

Auto Increment Oracle Table Id Mapping With JPA Entity

When you create entities file of the mysql table with JPA, auto increment field 'id' is mapped as follows.     @Id        @GeneratedValue(strategy = GenerationType.IDENTITY)     @Basic(optional = false)     @NotNull     @Column(name = "id")     private Long id; However, Oracle doesn't support auto increment. Hence sequence generator is set up for the field id of table. The respective entity mapping for 'id' should be changed as below.     @Id        @GeneratedValue(strategy = GenerationType.IDENTITY)     @Basic(optional = false)     @NotNull     @Column(name = "id")     private Long id;     @SequenceGenerator(initialValue=1, sequenceName="INVOICE_SEQ",allocationSize=1,name="invoice_seq_name")     @GeneratedValue(generator="invoice_s...

Configuring Oracle XE connection pool in Glassfish and Using JPA

To setup an Oracle Datasource in Glassfish, follow these steps: 1. Download and copy the Oracle JDBC driver (ojdbc14.jar ) to /glassfish/domains/domain1/lib/ext directory. 2. Start Glassfish. 3. Login to the admin interface and create a JDBC Connection Pool.     Delete all properties, and add following properties:     * user - set this to Oracle userid     * password - set this to Oracle password     * URL - set this to the URL, example jdbc:oracle:thin:@localhost:1521:xe.     * xa-driver-does-not-support-non-tx-operations - set this to true. Test the connection pool using ping. 4. Create a JDBC DataSource using the Connection Pool. If in case of Oracle major version error : javax.persistence.PersistenceException: org.hibernate.HibernateException: unknown Oracle major version [11] The fix for the error is add <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/...

Installing Java on Ubuntu Manually

Steps to follow: 1. Download jdk. I downloaded java7 from oracle's website. 2. Unzip and copy the folder into /usr/lib/jvm      Make directory jvm if it doesn't exist. I renamed the folder to java-7-oracle 3. Open /etc/environment and add this line      JAVA_HOME=/usr/lib/jvm/java-7-oracle      PATH=$PATH:$JAVA_HOME/bin 4. Then execute this command      source /etc/environment 5. On terminal type java -version to check if it shows the right version