Hibernate3.1 and Hibernate3.2

Source: Internet
Author: User
Tags generator

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.