» tagged pages
» logout

(Feed found, click Add Page to syndicate.) Error finding feed, please try again » Find feed title

A Blog Page allows you to add entries, for news or other time sensitive postings

(Login required to save to your tagged pages.)
(or Cancel)

Recent Edits

Eyal Lupu Java Blog

June 28

http://www.jroller.com/eyallupu http://www.jroller.com/page/eyallupu

Undo this change because:
editing undone by swikster

Hibernate

May 7

**More about Hibernate**: "Hibernate FAQs":http://www.developersbook.com/hibernate/interview-questions/hibernate-interview-questions-faqs.php....

» complete change

Hibernate is a powerful, high performance [[orm|object/relational persistence]] and query service for [[Java]]. [[NHibernate]] is a version of Hibernate for .NET.

**More about Hibernate**: "Hibernate FAQs":http://www.developersbook.com/hibernate/interview-questions/hibernate-interview-questions-faqs.php. Quiz":http://www.developersbook.com/hibernate/interview-questions/hibernate-interview-questions-faqs.php.

Hibernate lets you develop [[persistent objects]] following common [[Java]] idiom, including composition, association, inheritance, polymorphism, and the Java collections framework.

Hibernate is supported by JBoss/Redhat and [[SourceLabs]]. Hibernate is part of SourceLabs [[SASH]] distribution.

Hibernate is covered in SourceLabs "Self-support Suite for Linux and Open Source Java":http://www.sourcelabs.com

Hibernate code churn statistics are available "here":http://www.sourcelabs.com/?sidemenu=2&page=software&sub=dashboards&project=com.sourcelabs.sash.hibernate

Undo this change because:
edit by 146.243.4.157

Hibernate

May 6

**More about Hibernate**: "Hibernate Quiz":http://www.developersbook.com/hibernate/interview-questions/hibernate-interview-questions-faqs.php....

» complete change

Hibernate is a powerful, high performance [[orm|object/relational persistence]] and query service for [[Java]]. [[NHibernate]] is a version of Hibernate for .NET.

**More about Hibernate**: "Hibernate Quiz":http://www.developersbook.com/hibernate/interview-questions/hibernate-interview-questions-faqs.php. FAQs":http://www.developersbook.com/hibernate/interview-questions/hibernate-interview-questions-faqs.php.

Hibernate lets you develop [[persistent objects]] following common [[Java]] idiom, including composition, association, inheritance, polymorphism, and the Java collections framework.

Hibernate is supported by JBoss/Redhat and [[SourceLabs]]. Hibernate is part of SourceLabs [[SASH]] distribution.

Hibernate is covered in SourceLabs "Self-support Suite for Linux and Open Source Java":http://www.sourcelabs.com

Hibernate code churn statistics are available "here":http://www.sourcelabs.com/?sidemenu=2&page=software&sub=dashboards&project=com.sourcelabs.sash.hibernate

edit by djfink

Hibernate

March 19

Hibernate is covered in SourceLabs "Self-support Suite for Linux and Open Source Java":http://www.sourcelabs.com

Hibernate ...

» complete change

Hibernate is a powerful, high performance [[orm|object/relational persistence]] and query service for [[Java]]. [[NHibernate]] is a version of Hibernate for .NET.

**More about Hibernate**: "Hibernate FAQs":http://www.developersbook.com/hibernate/interview-questions/hibernate-interview-questions-faqs.php.

Hibernate lets you develop [[persistent objects]] following common [[Java]] idiom, including composition, association, inheritance, polymorphism, and the Java collections framework.

Hibernate is supported by JBoss/Redhat and [[SourceLabs]]. Hibernate is part of SourceLabs [[SASH]] distribution.

Hibernate is covered in SourceLabs "Self-support Suite for Linux and Open Source Java":http://www.sourcelabs.com

Hibernate code churn statistics are available "here":http://www.sourcelabs.com/?sidemenu=2&page=software&sub=dashboards&project=com.sourcelabs.sash.hibernate

Undo this change because:
editing undone by 122.163.231.17

Using SQL From Within Hibernate

February 26

I don't understand why that is a bad thing and why you would want to mix in two different ORM tools in your application. ...

» complete change

Most of the time [[Hibernate]] "just works". Therefore when it is not that easy is comes as somewhat of a surprise. Hibernate documentation says it is easy to use SQL from within Hibernate, but lets try it.

We can do it with using named [[SQL]] queries, or simply by embedding our SQL instructions directly in the source code.

h2. Embedding example : SQLCooperationTest.java

<pre>

public void runQuery(){

39 SQLQuery q = TestUtilities.getHSession().createSQLQuery

( "SELECT street, zip FROM sql_addresses");

40 q.addScalar( "street", Hibernate.STRING);

41 q.addScalar( "zip", Hibernate.STRING);

42 printResults( q );

43 }

</pre>

h2. Named SQL call example:

SQLCooperationTest.java

<pre>

46

47 public void runNamedQuery(){

48 SQLQuery q = ( SQLQuery ) TestUtilities.getHSession().getNamedQuery( "select_address" );

49 printResults( q );

50 }

</pre>

*and the definition of the named query is:

sql.hbm.xml*

<code>

<pre>

5

6 <hibernate-mapping package="com.sourcelabs.hibernate.bhw.bags" >

7

8 <sql-query name="select_address">

9 <return-scalar column="street" type="java.lang.String"/>

10 <return-scalar column="zip" type="java.lang.String"/>

11 select street, zip from sql_addresses

12 </sql-query>

13 </hibernate-mapping>

</pre>

</code>

as we can see in both cases we need to specify aliases and types for the query before it can be executed. If we do not do it then we will get exception like this:

<pre>

<code>

Caused by: org.hibernate.QueryException: addEntity() or addScalar() must be called on a sql query

before executing the query. [SELECT street, zip FROM sql_addresses]

at org.hibernate.impl.SQLQueryImpl.verifyParameters(SQLQueryImpl.java:169)

at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:140)

at com.sourcelabs.hibernate.bhw.sql.SQLCooperationTest.printResults(SQLCooperationTest.java:52)

at com.sourcelabs.hibernate.bhw.sql.SQLCooperationTest.runQuery(SQLCooperationTest.java:43)

at com.sourcelabs.hibernate.bhw.sql.SQLCooperationTest$$FastClassByCGLIB$$79fd0338.

invoke(<generated>)

at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)

at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept

(Cglib2AopProxy.java:635)

at com.sourcelabs.hibernate.bhw.sql.SQLCooperationTest$$EnhancerByCGLIB$$511db1d7.

runQuery(<generated>)

</code>

</pre>

This default behavior is somehow odd and counterintuitive because H can return an array of object by default, but for unclear reasons H does not do that. Another potentially useful feature could be returning an array of maps. And again there is enough information at runtime to make intelligent mapping of columns to keys and values.

Hibernate perhaps could learn something from [[iBatis]]. If you need to use complex and/or RDBMS specific SQL extensively throughout then you might consider using Hibernate and iBatis together.

I don't understand why that is a bad thing and why you would want to mix in two different ORM tools in your application. Just always use aliases, and if it isn't to an object already mapped then include the types. Also taken directly from Hibernate's documentation you can find..

"It is possible to leave out the type information for all or some of the scalars.

sess.createSQLQuery("SELECT * FROM CATS")

.addScalar("ID", Hibernate.LONG)

.addScalar("NAME")

.addScalar("BIRTHDATE")

"

Hmm, no alias there, but in your query you have a where clause so I highly recommend an alias anyway.

Undo this change because:
edit by 146.243.4.157

Hibernate

February 21

**More More about Hibernate**: Hibernate: "Hibernate FAQs":http://www.developersbook.com/hibernate/interview-questions/hibernate-interview-questions-faqs.php....

» complete change

Hibernate is a powerful, high performance [[orm|object/relational persistence]] and query service for [[Java]]. [[NHibernate]] is a version of Hibernate for .NET.

**More More about Hibernate**: Hibernate: "Hibernate FAQs":http://www.developersbook.com/hibernate/interview-questions/hibernate-interview-questions-faqs.php.

Hibernate lets you develop [[persistent objects]] following common [[Java]] idiom, including composition, association, inheritance, polymorphism, and the Java collections framework.

Hibernate is supported by JBoss/Redhat and [[SourceLabs]]. Hibernate is part of SourceLabs [[SASH]] distribution.

Hibernate code churn statistics are available "here":http://www.sourcelabs.com/?sidemenu=2&page=software&sub=dashboards&project=com.sourcelabs.sash.hibernate

edit by 146.243.4.157

Hibernate

February 21

More about Hibernate: "Hibernate FAQs":http://www.developersbook.com/hibernate/interview-questions/hibernate-interview-questions-faqs.php....

» complete change

Hibernate is a powerful, high performance [[orm|object/relational persistence]] and query service for [[Java]]. [[NHibernate]] is a version of Hibernate for .NET.

More about Hibernate: "Hibernate FAQs":http://www.developersbook.com/hibernate/interview-questions/hibernate-interview-questions-faqs.php.

Hibernate lets you develop [[persistent objects]] following common [[Java]] idiom, including composition, association, inheritance, polymorphism, and the Java collections framework.

Hibernate is supported by JBoss/Redhat and [[SourceLabs]]. Hibernate is part of SourceLabs [[SASH]] distribution.

Hibernate code churn statistics are available "here":http://www.sourcelabs.com/?sidemenu=2&page=software&sub=dashboards&project=com.sourcelabs.sash.hibernate

edit by 71.233.98.66

Hibernate

January 29

"Hibernate FAQs":http://www.developersbook.com/hibernate/interview-questions/hibernate-interview-questions-faqs.php.

Hibernate...

» complete change

Hibernate is a powerful, high performance [[orm|object/relational persistence]] and query service for [[Java]]. [[NHibernate]] is a version of Hibernate for .NET.

"Hibernate FAQs":http://www.developersbook.com/hibernate/interview-questions/hibernate-interview-questions-faqs.php.

Hibernate lets you develop [[persistent objects]] following common [[Java]] idiom, including composition, association, inheritance, polymorphism, and the Java collections framework.

Hibernate is supported by JBoss/Redhat and [[SourceLabs]]. Hibernate is part of SourceLabs [[SASH]] distribution.

Hibernate code churn statistics are available "here":http://www.sourcelabs.com/?sidemenu=2&page=software&sub=dashboards&project=com.sourcelabs.sash.hibernate

edit by 71.189.61.236

Using SQL From Within Hibernate

September 9, 2007

I don't understand why that is a bad thing and why you would want to mix in two different ORM tools in your application. ...

» complete change

Most of the time [[Hibernate]] "just works". Therefore when it is not that easy is comes as somewhat of a surprise. Hibernate documentation says it is easy to use SQL from within Hibernate, but lets try it.

We can do it with using named [[SQL]] queries, or simply by embedding our SQL instructions directly in the source code.

h2. Embedding example : SQLCooperationTest.java

<pre>

public void runQuery(){

39 SQLQuery q = TestUtilities.getHSession().createSQLQuery

( "SELECT street, zip FROM sql_addresses");

40 q.addScalar( "street", Hibernate.STRING);

41 q.addScalar( "zip", Hibernate.STRING);

42 printResults( q );

43 }

</pre>

h2. Named SQL call example:

SQLCooperationTest.java

<pre>

46

47 public void runNamedQuery(){

48 SQLQuery q = ( SQLQuery ) TestUtilities.getHSession().getNamedQuery( "select_address" );

49 printResults( q );

50 }

</pre>

*and the definition of the named query is:

sql.hbm.xml*

<code>

<pre>

5

6 <hibernate-mapping package="com.sourcelabs.hibernate.bhw.bags" >

7

8 <sql-query name="select_address">

9 <return-scalar column="street" type="java.lang.String"/>

10 <return-scalar column="zip" type="java.lang.String"/>

11 select street, zip from sql_addresses

12 </sql-query>

13 </hibernate-mapping>

</pre>

</code>

as we can see in both cases we need to specify aliases and types for the query before it can be executed. If we do not do it then we will get exception like this:

<pre>

<code>

Caused by: org.hibernate.QueryException: addEntity() or addScalar() must be called on a sql query

before executing the query. [SELECT street, zip FROM sql_addresses]

at org.hibernate.impl.SQLQueryImpl.verifyParameters(SQLQueryImpl.java:169)

at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:140)

at com.sourcelabs.hibernate.bhw.sql.SQLCooperationTest.printResults(SQLCooperationTest.java:52)

at com.sourcelabs.hibernate.bhw.sql.SQLCooperationTest.runQuery(SQLCooperationTest.java:43)

at com.sourcelabs.hibernate.bhw.sql.SQLCooperationTest$$FastClassByCGLIB$$79fd0338.

invoke(<generated>)

at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)

at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept

(Cglib2AopProxy.java:635)

at com.sourcelabs.hibernate.bhw.sql.SQLCooperationTest$$EnhancerByCGLIB$$511db1d7.

runQuery(<generated>)

</code>

</pre>

This default behavior is somehow odd and counterintuitive because H can return an array of object by default, but for unclear reasons H does not do that. Another potentially useful feature could be returning an array of maps. And again there is enough information at runtime to make intelligent mapping of columns to keys and values.

Hibernate perhaps could learn something from [[iBatis]]. If you need to use complex and/or RDBMS specific SQL extensively throughout then you might consider using Hibernate and iBatis together.

I don't understand why that is a bad thing and why you would want to mix in two different ORM tools in your application. Just always use aliases, and if it isn't to an object already mapped then include the types. Also taken directly from Hibernate's documentation you can find..

"It is possible to leave out the type information for all or some of the scalars.

sess.createSQLQuery("SELECT * FROM CATS")

.addScalar("ID", Hibernate.LONG)

.addScalar("NAME")

.addScalar("BIRTHDATE")

"

Hmm, no alias there, but in your query you have a where clause so I highly recommend an alias anyway.

edit by 71.189.61.236

Using SQL From Within Hibernate

September 9, 2007

I don't understand why that is a bad thing and why you would want to mix in two different ORM tools in your application. ...

» complete change

Most of the time [[Hibernate]] "just works". Therefore when it is not that easy is comes as somewhat of a surprise. Hibernate documentation says it is easy to use SQL from within Hibernate, but lets try it.

We can do it with using named [[SQL]] queries, or simply by embedding our SQL instructions directly in the source code.

h2. Embedding example : SQLCooperationTest.java

<pre>

public void runQuery(){

39 SQLQuery q = TestUtilities.getHSession().createSQLQuery

( "SELECT street, zip FROM sql_addresses");

40 q.addScalar( "street", Hibernate.STRING);

41 q.addScalar( "zip", Hibernate.STRING);

42 printResults( q );

43 }

</pre>

h2. Named SQL call example:

SQLCooperationTest.java

<pre>

46

47 public void runNamedQuery(){

48 SQLQuery q = ( SQLQuery ) TestUtilities.getHSession().getNamedQuery( "select_address" );

49 printResults( q );

50 }

</pre>

*and the definition of the named query is:

sql.hbm.xml*

<code>

<pre>

5

6 <hibernate-mapping package="com.sourcelabs.hibernate.bhw.bags" >

7

8 <sql-query name="select_address">

9 <return-scalar column="street" type="java.lang.String"/>

10 <return-scalar column="zip" type="java.lang.String"/>

11 select street, zip from sql_addresses

12 </sql-query>

13 </hibernate-mapping>

</pre>

</code>

as we can see in both cases we need to specify aliases and types for the query before it can be executed. If we do not do it then we will get exception like this:

<pre>

<code>

Caused by: org.hibernate.QueryException: addEntity() or addScalar() must be called on a sql query

before executing the query. [SELECT street, zip FROM sql_addresses]

at org.hibernate.impl.SQLQueryImpl.verifyParameters(SQLQueryImpl.java:169)

at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:140)

at com.sourcelabs.hibernate.bhw.sql.SQLCooperationTest.printResults(SQLCooperationTest.java:52)

at com.sourcelabs.hibernate.bhw.sql.SQLCooperationTest.runQuery(SQLCooperationTest.java:43)

at com.sourcelabs.hibernate.bhw.sql.SQLCooperationTest$$FastClassByCGLIB$$79fd0338.

invoke(<generated>)

at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)

at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept

(Cglib2AopProxy.java:635)

at com.sourcelabs.hibernate.bhw.sql.SQLCooperationTest$$EnhancerByCGLIB$$511db1d7.

runQuery(<generated>)

</code>

</pre>

This default behavior is somehow odd and counterintuitive because H can return an array of object by default, but for unclear reasons H does not do that. Another potentially useful feature could be returning an array of maps. And again there is enough information at runtime to make intelligent mapping of columns to keys and values.

Hibernate perhaps could learn something from [[iBatis]]. If you need to use complex and/or RDBMS specific SQL extensively throughout then you might consider using Hibernate and iBatis together.

I don't understand why that is a bad thing and why you would want to mix in two different ORM tools in your application. Just always use aliases, and if it isn't to an object already mapped then include the types.

Undo this change because:
edit by swikfan

Hibernate

September 7, 2007

Hibernate is a powerful, high performance [[orm|object/relational persistence]] and query service for [[Java]]. [[NHibernate]]...

» complete change

Hibernate is a powerful, high performance [[orm|object/relational persistence]] and query service for [[Java]]. [[NHibernate]] is a version of Hibernate for .NET.

Hibernate lets you develop [[persistent objects]] following common [[Java]] idiom, including composition, association, inheritance, polymorphism, and the Java collections framework.

Hibernate is supported by JBoss/Redhat and [[SourceLabs]]. Hibernate is part of SourceLabs [[SASH]] distribution.

Hibernate code churn statistics are available "here":http://www.sourcelabs.com/?sidemenu=2&page=software&sub=dashboards&project=com.sourcelabs.sash.hibernate

edit by swikfan

Hibernate

August 24, 2007

Hibernate is supported by JBoss/Redhat and [[SourceLabs]]. Hibernate is part of SourceLabs [[SASH]] distribution.

Hibernate...

» complete change

Hibernate is a powerful, high performance [[orm|object/relational persistence]] and query service for [[Java]].

Hibernate lets you develop [[persistent objects]] following common [[Java]] idiom, including composition, association, inheritance, polymorphism, and the Java collections framework.

Hibernate is supported by JBoss/Redhat and [[SourceLabs]]. Hibernate is part of SourceLabs [[SASH]] distribution.

Hibernate code churn statistics are available "here":http://www.sourcelabs.com/?sidemenu=2&page=software&sub=dashboards&project=com.sourcelabs.sash.hibernate

Hibernate

August 3, 2007

Hibernate code churn statistics are available "here":http://www.sourcelabs.com/?sidemenu=2&page=software&sub=dashboards&project=com.sourcelabs.sash.hibernate...

» complete change

Hibernate is a powerful, high performance [[orm|object/relational persistence]] and query service for [[Java]].

Hibernate lets you develop [[persistent objects]] following common [[Java]] idiom, including composition, association, inheritance, polymorphism, and the Java collections framework.

Hibernate code churn statistics are available "here":http://www.sourcelabs.com/?sidemenu=2&page=software&sub=dashboards&project=com.sourcelabs.sash.hibernate

Hibernate

August 3, 2007
Hibernate
Undo this change because:
editing undone by 122.167.25.180

Eyal Lupu Java Blog

July 19, 2007
Links Blog
Undo this change because:
deleted by dland

how to configure JNDI in hibernate3 and jboss

July 9, 2007
The page and its contents were erased.

Hi

how to configure JNDI in hibernate3 ,and what is the use of using JNDI lookup in hibernate

can anybody explain me

Undo this change because:
created by mnrnjn

how to configure JNDI in hibernate3 and jboss

July 9, 2007
The page was created.
how to configure JNDI in hibernate3 and jboss
Article

Hi

how to configure JNDI in hibernate3 ,and what is the use of using JNDI lookup in hibernate

can anybody explain me

edit by yonyon

Eyal Lupu Java Blog

May 29, 2007
Blog Links
created by yonyon

Eyal Lupu Java Blog

May 29, 2007
The page was created.
Eyal Lupu Java Blog
Links

http://www.jroller.com/page/eyallupu

Undo this change because:
deleted by alex

Downloads

February 17, 2007
The page and its contents were erased.
Undo this change because:
re-created by 24.15.187.91

Downloads

February 16, 2007
The page was created.
Undo this change because:
created by swikfan

On Java article about Hibernate 3 Annotations

February 16, 2007
The entry was created.
http://www.onjava.com/pub/a/onjava/2007/02/08/an-introduction-to-hibernate-3-annotations.html
On Java article about Hibernate 3 Annotations
Undo this change because:
deleted by alex

Downloads

February 16, 2007
The page and its contents were erased.
Undo this change because:
re-created by 87.15.180.83

Downloads

February 16, 2007
“fgc”
The page was created.
deleted by 202.75.198.230

Downloads

February 16, 2007
The page and its contents were erased.
Undo this change because:
deleted by 202.75.198.230

http://prdownloads.sourceforge.net/jboss/HibernateTools-3.1.0.beta1.zip?download

February 16, 2007
The entry and its contents were erased.
http://prdownloads.sourceforge.net/jboss/HibernateTools-3.1.0.beta1.zip?download
Undo this change because:
edit by alex

Hibernate

December 5, 2006
“link not notable to hibernate project - keep this to kibbitzer page”

"Hibernate metrics":http://www.sourcekibitzer.org/index.php?option=com_skproject&task=view&projectid=hibernate3

» complete change

Hibernate is a powerful, high performance [[orm|object/relational persistence]] and query service for [[Java]].

Hibernate lets you develop [[persistent objects]] following common [[Java]] idiom, including composition, association, inheritance, polymorphism, and the Java collections framework.

"Hibernate metrics":http://www.sourcekibitzer.org/index.php?option=com_skproject&task=view&projectid=hibernate3

Hibernate

December 5, 2006

"Hibernate metrics":http://www.sourcekibitzer.org/index.php?option=com_skproject&task=view&projectid=hibernate3 metrics":http://www.sourcekibitzer.org/project.php?name=Hibernate3&path=jboss/hibernate-3/trunk/...

» complete change

Hibernate is a powerful, high performance [[orm|object/relational persistence]] and query service for [[Java]].

Hibernate lets you develop [[persistent objects]] following common [[Java]] idiom, including composition, association, inheritance, polymorphism, and the Java collections framework.

"Hibernate metrics":http://www.sourcekibitzer.org/index.php?option=com_skproject&task=view&projectid=hibernate3 metrics":http://www.sourcekibitzer.org/project.php?name=Hibernate3&path=jboss/hibernate-3/trunk/

deleted by alex

hibernate exception Hibernate Dialect must be explicitly set

November 15, 2006
“this isn't a hibernate forum - people wont' see this to help you”
The page and its contents were erased.
Hibernate

Hi

I am trying to do a simple application in hibernate.

I created the following classes and i am trying to insert one record...

» complete change

Hi

I am trying to do a simple application in hibernate.

I created the following classes and i am trying to insert one record into table "contact"

but its showing an exception

org.hibernate.HibernateException: Hibernate Dialect must be explicitly set

at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:57)

at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:39)

at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:378)

at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:110)

at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1881)

at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1174)

at FirstExample.main(FirstExample.java:12)

here is the code

<?xml version='1.0' encoding='utf-8'?>

<!DOCTYPE hibernate-configuration PUBLIC

"-//Hibernate/Hibernate Configuration DTD//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

<session-factory>

<property name="hibernate.connection.driver_class">com.ibm.db2.jdbc.app.DB2Driver</property>

<property name="hibernate.connection.url">jdbc:db2:MWCDPDB2</property>

<property name="hibernate.connection.username">db2admin</property>

<property name="hibernate.connection.password">vimal</property>

<property name="hibernate.connection.pool_size">10</property>

<property name="show_sql">true</property>

<property name="dialect">org.hibernate.dialect.DB2Dialect</property>

<property name="hibernate.hbm2ddl.auto">update</property>

<!-- Mapping files -->

<mapping resource="Contact.hbm.xml"/>

</session-factory>

</hibernate-configuration>

<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC

"-//Hibernate/Hibernate Mapping DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

<class name="Contact" table="CONTACT">

<id name="id" type="int" column="ID" >

<generator class="assigned"/>

</id>

<property name="firstName">

<column name="FIRSTNAME" />

</property>

<property name="lastName">

<column name="LASTNAME"/>

</property>

<property name="email">

<column name="EMAIL"/>

</property>

</class>

</hibernate-mapping>

public class Contact {

private String firstName;

private String lastName;

private String email;

private int id;

/**

* @return Email

*/

public String getEmail() {

return email;

}

/**

* @return First Name

*/

public String getFirstName() {

return firstName;

}

/**

* @return Last name

*/

public String getLastName() {

return lastName;

}

/**

* @param string Sets the Email

*/

public void setEmail(String string) {

email = string;

}

/**

* @param string Sets the First Name

*/

public void setFirstName(String string) {

firstName = string;

}

/**

* @param string sets the Last Name

*/

public void setLastName(String string) {

lastName = string;

}

/**

* @return ID Returns ID

*/

public int getId() {

return id;

}

/**

* @param l Sets the ID

*/

public void setId(int l) {

id = l;

}

}

import org.hibernate.Session;

import org.hibernate.SessionFactory;

import org.hibernate.cfg.Configuration;

import org.hibernate.HibernateException;

public class FirstExample {

public static void main(String[] args) {

try{

Configuration cfg1=new Configuration().addClass(Contact.class);

System.out.println("comes here"+cfg1);

SessionFactory sessionFactory=cfg1.buildSessionFactory();

System.out.println("comes here"+sessionFactory);

Session session =sessionFactory.openSession();

System.out.println("Inserting Record");

Contact contact = new Contact();

contact.setId(3);

contact.setFirstName("Deepak");

contact.setLastName("Kumar");

contact.setEmail("deepak_38@yahoo.com");

session.save(contact);

System.out.println("Done");

session.flush();

session.close();

}catch(HibernateException e){

e.printStackTrace();

}

}

}

here i am getting the problem at line ---- SessionFactory sessionFactory=cfg1.buildSessionFactory();

could you pls help me

thanks

madhu

Undo this change because:
created by mkarunat

hibernate exception Hibernate Dialect must be explicitly set

November 15, 2006
The page was created.
Hibernate
hibernate exception Hibernate Dialect must be explicitly set
Article

Hi

I am trying to do a simple application in hibernate.

I created the following classes and i am trying to insert one record...

» complete change

Hi

I am trying to do a simple application in hibernate.

I created the following classes and i am trying to insert one record into table "contact"

but its showing an exception

org.hibernate.HibernateException: Hibernate Dialect must be explicitly set

at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:57)

at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:39)

at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:378)

at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:110)

at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1881)

at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1174)

at FirstExample.main(FirstExample.java:12)

here is the code

<?xml version='1.0' encoding='utf-8'?>

<!DOCTYPE hibernate-configuration PUBLIC

"-//Hibernate/Hibernate Configuration DTD//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

<session-factory>

<property name="hibernate.connection.driver_class">com.ibm.db2.jdbc.app.DB2Driver</property>

<property name="hibernate.connection.url">jdbc:db2:MWCDPDB2</property>

<property name="hibernate.connection.username">db2admin</property>

<property name="hibernate.connection.password">vimal</property>

<property name="hibernate.connection.pool_size">10</property>

<property name="show_sql">true</property>

<property name="dialect">org.hibernate.dialect.DB2Dialect</property>

<property name="hibernate.hbm2ddl.auto">update</property>

<!-- Mapping files -->

<mapping resource="Contact.hbm.xml"/>

</session-factory>

</hibernate-configuration>

<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC

"-//Hibernate/Hibernate Mapping DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

<class name="Contact" table="CONTACT">

<id name="id" type="int" column="ID" >

<generator class="assigned"/>

</id>

<property name="firstName">

<column name="FIRSTNAME" />

</property>

<property name="lastName">

<column name="LASTNAME"/>

</property>

<property name="email">

<column name="EMAIL"/>

</property>

</class>

</hibernate-mapping>

public class Contact {

private String firstName;

private String lastName;

private String email;

private int id;

/**

* @return Email

*/

public String getEmail() {

return email;

}

/**

* @return First Name

*/

public String getFirstName() {

return firstName;

}

/**

* @return Last name

*/

public String getLastName() {

return lastName;

}

/**

* @param string Sets the Email

*/

public void setEmail(String string) {

email = string;

}

/**

* @param string Sets the First Name

*/

public void setFirstName(String string) {

firstName = string;

}

/**

* @param string sets the Last Name

*/

public void setLastName(String string) {

lastName = string;

}

/**

* @return ID Returns ID

*/

public int getId() {

return id;

}

/**

* @param l Sets the ID

*/

public void setId(int l) {

id = l;

}

}

import org.hibernate.Session;

import org.hibernate.SessionFactory;

import org.hibernate.cfg.Configuration;

import org.hibernate.HibernateException;

public class FirstExample {

public static void main(String[] args) {

try{

Configuration cfg1=new Configuration().addClass(Contact.class);

System.out.println("comes here"+cfg1);

SessionFactory sessionFactory=cfg1.buildSessionFactory();

System.out.println("comes here"+sessionFactory);

Session session =sessionFactory.openSession();

System.out.println("Inserting Record");

Contact contact = new Contact();

contact.setId(3);

contact.setFirstName("Deepak");

contact.setLastName("Kumar");

contact.setEmail("deepak_38@yahoo.com");

session.save(contact);

System.out.println("Done");

session.flush();

session.close();

}catch(HibernateException e){

e.printStackTrace();

}

}

}

here i am getting the problem at line ---- SessionFactory sessionFactory=cfg1.buildSessionFactory();

could you pls help me

thanks

madhu

edit by madmak

Hibernate

October 13, 2006
“Added metrics report link”

"Hibernate metrics":http://www.sourcekibitzer.org/project.php?name=Hibernate3&path=jboss/hibernate-3/trunk/

» complete change

Hibernate is a powerful, high performance [[orm|object/relational persistence]] and query service for [[Java]].

Hibernate lets you develop [[persistent objects]] following common [[Java]] idiom, including composition, association, inheritance, polymorphism, and the Java collections framework.

"Hibernate metrics":http://www.sourcekibitzer.org/project.php?name=Hibernate3&path=jboss/hibernate-3/trunk/

created by 207.170.200.19

Transactions and concurrency

October 11, 2006
The entry was created.
Hibernate
http://hibernate.org/hib_docs/v3/reference/en/html/transactions.html
Transactions and concurrency
Undo this change because:
editing re-applied 61.95.184.98

Hibernate BAG vs IDBAG Performance Comparison

October 9, 2006
Hibernate BAG IDBAG Comparison

_Compare performance of bag and idbag mappings._(Created before October 1st, 2006) mappings._

» complete change

_Compare performance of bag and idbag mappings._(Created before October 1st, 2006) mappings._

[[Hibernate]] is well known for its ability to help developers to persist collections of dependent elements, but that comes at a price. What is the the cost?

Hibernate provides us with numerous mapping options, but let's focus on two: bag, and idbag. On the application code level the usage of bag and idbag tags is exactly the same. The differences are hidden in the Hibernate mapping files and in the database schema. Let's look at the DB schema:

h2. create-db.sql

<pre>

1

2 CREATE TABLE bag_main_objects (

3 id varchar(40) PRIMARY KEY,

4 name varchar(100)

5 );

6

7 CREATE TABLE idbag_dependent_objects (

8 id varchar(40) PRIMARY KEY,

9 main_id varchar(40),

10 val char(255)

11 );

12

13 CREATE TABLE bag_dependent_objects (

14 main_id varchar(40),

15 val char(255)

16 );

17

</pre>

Here we create do tables for dependent objects: table bag_dependent_object does not have a surrogate key, and table idbag_dependent_objects that has surrogate key. For simplicity we will just have values in the dependent objects table, but we as well could store keys to another table that will allow us to implements many-to-many relationships.

Then we will populate those tables with 100 main object and with 20 dependent objects per main object.

h2. DBSetterImpl.java

<pre>

27

28 public void generateTestData( Connection c ) throws SQLException{

29 for( int main_id = 0; main_id < MAIN_OBJ_ID_LIMIT; main_id++){

30 exec( c, "INSERT INTO bag_main_objects (id, name ) VALUES ( '"+ main_id +"','main-obj-"

+ main_id + "')");

31 for( int j = 0; j < DEPENDENT_OBJ_LIMIT; j++ ){

32 exec( c, "INSERT INTO idbag_dependent_objects(id, main_id, val) VALUES " +

33 "( 'm"+ main_id + "d"+ j +"','" + main_id + "','value of " +main_id + "d"+ j +"')");

34 exec( c, "INSERT INTO bag_dependent_objects(main_id, val) VALUES " +

35 "('" + main_id + "','value of " +main_id + "d"+ j

+"kjhdsafjhsjhdfkhgskjhdfkjhsgkdjfhgkjshdfgk asjfhdg akksddg aslkdkhfg alsidf')");

36 }

37 }

38 }

</pre>

BAG mapping is the example of un-optimized collection handling, it sure looks nice in the code: we simply add, update, or delete objects from the collection and Hibernate stores our changes. However for bag Hibernate uses a rather brutal force strategy: it deletes all the relevant rows from decent objects table and then inserts all the current collection content back into the database.

For example, lets assume that we have 20 dependent objects in a collection of dependent objects. If we delete just one object from the collection then Hibernate will execute 1 delete statement to delete all 20 rows, and then 19 insert statements to insert remaining 19 objects back into the database.

Here is how the mapping file looks:

h2. bag.hbm.xml

<code>

<pre>

5

6 <hibernate-mapping package="com.sourcelabs.hibernate.bhw.bags" >

7

8 <class table="bag_main_objects" name="BagContainerObj" lazy="false" >

9 <id name="id" >

10 <generator class="uuid"/>

11 </id>

12 <property name="name" />

13 <bag name="dependentObjects" table="bag_dependent_objects" lazy="false">

14 <key column="main_id" />

15 <element type="java.lang.String" column="val"/>

16 </bag>

17 </class>

18 </hibernate-mapping>

</pre>

</code>

IDBAG mapping is much smarter than BAG but requires ID column in the table of dependent objects. When we change collection content or update its members Hibernate will issue only necessary [[SQL]] update statements. If we delete one object from the collection, then Hibernate will execute only one SQL delete statement. IDBAG mapping looks as the following:

h2. idbag.hbm.xml

<code>

<pre>

<hibernate-mapping package="com.sourcelabs.hibernate.bhw.bags" >

6

7 <class table="bag_main_objects" name="BagContainerObj" lazy="false" >

8 <id name="id" >

9 <generator class="uuid"/>

10 </id>

11 <property name="name" />

12 <idbag name="dependentObjects" table="idbag_dependent_objects" lazy="false">

13 <collection-id column="id" type="java.lang.String">

14 <generator class="uuid"/>

15 </collection-id>

16 <key column="main_id" />

17 <element type="java.lang.String" column="val"/>

18 </idbag>

19 </class>

20 </hibernate-mapping>

</pre>

</code>

Both our mappings map collection of Strings to a list field for the same object, that is right, the same object have two different mappings, they of course cannot be used simultaneously in the same session, therefore we will run our tests sequentially:

h2. BagContainerObj.java

<pre>

public class BagContainerObj {

11 String id;

12 String name;

13 List dependentObjects;

14

15 public String getId(){

16 return id;

17 }

18

19 public void setId( String id ){

20 this.id = id;

21 }

22

23 public String getName(){

24 return name;

25 }

26

27 public void setName( String name ){

28 this.name = name;

29 }

30

31 public List getDependentObjects(){

32 return dependentObjects;

33 }

34

35 public void setDependentObjects( List dependentObjects ){

36 this.dependentObjects = dependentObjects;

37 }

38 }

39

</pre>

Running our tests produces the expected results: IDBAG collection is approximately 5 times faster than BAG mapping. And the advantage of IDBAG becomes even more noticeable with increase in the number of objects in the collection.

<pre>

run-class:

[java] [main] WARN net.sf.ehcache.config.Configurator

- No configuration found. Configuring ehcache

from ehcache -failsafe.xml found in the classpath: jar:file:

/home/kosta/.m2/repository/net/sf/ehcache/ehcache

/1.1-1/ehcache-1.1-1.jar!/ehcache-failsafe.xml

[java] USING BAG

[java] 613 [main] INFO org.springframework.aop.framework.DefaultAopProxyFactory

- CGLIB2 available: pro

xyTargetClass feature enabled

[java] 616 [main] INFO org.springframework.core.CollectionFactory

- JDK 1.4+ collections available

[java] 627 [main] INFO org.springframework.core.CollectionFactory

- Commons Collections 3.x available

[java] Pass #1

[java] hibernateSessionFactory = org.hibernate.impl.SessionFactoryImpl@1d95da8

[java] execAddElement 1716 ms

[java] Pass #2

[java] hibernateSessionFactory = org.hibernate.impl.SessionFactoryImpl@1d95da8

[java] execAddElement 1372 ms

[java] Pass #3

[java] hibernateSessionFactory = org.hibernate.impl.SessionFactoryImpl@1d95da8

[java] execAddElement 1178 ms

[java] Average::1422.3333333333333 ms

[java] USING IDBAG

[java] Pass #1

[java] hibernateSessionFactory = org.hibernate.impl.SessionFactoryImpl@1a3b359

[java] execAddElement 485 ms

[java] Pass #2

[java] hibernateSessionFactory = org.hibernate.impl.SessionFactoryImpl@1a3b359

[java] execAddElement 438 ms

[java] Pass #3

[java] hibernateSessionFactory = org.hibernate.impl.SessionFactoryImpl@1a3b359

[java] execAddElement 526 ms

[java] Average::483.6666666666667 ms

[java] USING BAG

[java] Pass #1

[java] hibernateSessionFactory = org.hibernate.impl.SessionFactoryImpl@1d95da8

[java] execRemoveElement 1367 ms

[java] Pass #2

[java] hibernateSessionFactory = org.hibernate.impl.SessionFactoryImpl@1d95da8

[java] execRemoveElement 1292 ms

[java] Pass #3

[java] hibernateSessionFactory = org.hibernate.impl.SessionFactoryImpl@1d95da8

[java] execRemoveElement 1353 ms

[java] Average::1337.3333333333333 ms

[java] USING IDBAG

[java] Pass #1

[java] hibernateSessionFactory = org.hibernate.impl.SessionFactoryImpl@1a3b359

[java] execRemoveElement 413 ms

[java] Pass #2

[java] hibernateSessionFactory = org.hibernate.impl.SessionFactoryImpl@1a3b359

[java] execRemoveElement 419 ms

[java] Pass #3

[java] hibernateSessionFactory = org.hibernate.impl.SessionFactoryImpl@1a3b359

[java] execRemoveElement 402 ms

[java] Average::411.6666666666667 ms

</pre>

The testing environment:

<pre>

kosta@swan ~/dev/hb-beyond-hw $ java -version

java version "1.5.0_06"

Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)

Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode)

kosta@swan ~/dev/hb-beyond-hw $ uname -a

Linux swan 2.6.14-gentoo-r2 #1 SMP Wed Dec 21 09:41:13

PST 2005 x86_64 Intel(R) Xeon(TM) CPU 2.80GHz GenuineIntel GNU/Linux

</pre>

*BAGs brute force strategy is surely necessary for update and delete operations, but Hibernate could do a better job optimizing add (insert) operations. There is a little need for deleteing and reinserting all the members of the collection just to add one more record.*

editing undone by 61.95.184.98

Hibernate BAG vs IDBAG Performance Comparison

October 9, 2006
“sdffbh”