Today in the work found a problem, I hope to give you some inspiration, I do not have a deep understanding of the hibernate, but in the project to use some superficial methods, the bottom of the talk about Hibernate3.1 and Hibernate3.2 related to some things.
Today is running a very simple Save () Method report:
Exception in thread "main" net.sf.hibernate.MappingException:
Dialect does not support identity key generation
at net.sf.hibernate.dialect.Dialect.gerIdentitySelectString(Dialect.java:305)
at net.sf.hibernate.persister.AbstracEntityPersister.<init> (AbstractEntityPersister.java:646)
at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:690)
at net.sf.hibernate.persister.PersisterFactory.createClassPersister
For a moment really really put me to stop a bit, or send a little time to see, just developed the project is the same configuration everything is very smooth, this time how to report this anomaly,
It's just beginning to focus on. Hbm.xml file mapping, but are hibernate inversion control generated, there is no error.
Or the network is good, in the CSDN network to find a solution to this problem, automatic growth of the field: values can be increment, identity, sequence, hilo, native ... Wait
Put the configuration file by this:
<id name="kid" type="java.lang.Long">
<column name="KID" precision="22" scale="0" />
<generator class="identity"/>
</id>
To
<id name="kid" type="java.lang.Long">
<column name="KID" precision="22" scale="0" />
<generator class="increment"/>
</id>
As a result, everything runs successfully.
I do not understand the specific reasons, there is no time, only know, in the use of identity is used and Hibernate3.1 jar, and hibernate3.2 will throw an exception, the use of increment will not. Specifically, here Hibernate3.1 and Hibernate3.2 exactly what the difference is, perhaps also need in-depth research.