Jason B Herald x = sin x

3Jun/080

Absolute Link

This is a fantastic link for finding information about EJB and Hibernate Annotations. So thanks to the guys/gals that produced it:

Link to Content

Filed under: EJB, Hibernate, Java No Comments
20May/080

Common Hibernate Options (hibernate.cfg.xml)

Below is a pretty standard configuration which appears to work quickly using an oracle database with a datasource defined in an oracle application server.  I will be refining this over the next week as I performance tune the "massive app".

<property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
<property name="connection.datasource">jdbc/xxx</property>
<property name="current_session_context_class">thread</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">none</property>
<property name="connection.pool_size">5</property>
<property name="hibernate.max_fetch_depth">0</property>
<property name="hibernate.use_reflection_optimizer">true</property>
<property name="use_outer_join">false</property>

Filed under: Hibernate, Java No Comments
16May/080

Hql Basics (Parameters)

In using Hibernate Query Language to include a Parameter of Type Long in a statement you would use the following code:

Query q = session.createQuery("from Class1 c where c.class2.class2_id = :class2_id");
q.setLong("class2_id", class2_id);
q.list();.....

One thing to Immediately notice (if you are familiar with Hibernate) is that I am calling class2_id through class2.  This is because in my little world class2 has a one to many relationship with Class1.  This means there is an object called class2 joining them together in the annotations.  However, I digress.  The real take away is that a parameter called :class2_id was established in the query and the referenced in the setLong statement to set the value.  After that calling the q.list function will return the values pulled back from the query. And TADA!

Filed under: Hibernate, Java No Comments
   

 

September 2010
M T W T F S S
« Aug    
 12345
6789101112
13141516171819
20212223242526
27282930  

Categories

Pages