Java – does hibernate’s generator class really work?

After several hours of frustration with me and my eclipse, I raise this question here I hope to find some breathing opportunities here

I am trying to save POJO objects to MySQL database through hibernate 3.0 Basically, my requirement is: I need to assign an ID to the object before saving, rather than let hibernate do it for me

For this reason, I found and found < generator class = "assigned" / > in the document, which is very suitable for my bill So I passed hbm. The XML file updates the following ID:

<id name="id" type="int">
    <column name="ID" />
    <generator class="assigned" />
</id>

My POJO will hbm. XML file matches t

I'm setting all the parameters, including my POJO ID and calling hibernate's saveOrUpdate (object) method

If there is any help, the ID column of my database table has "auto Inc" disabled

Incredibly, when I looked at the contents of the database table, I inserted a row of Hibernate's own ID instead of what I set

How is that possible? Is there anything else that affects your ID card? Did I miss anything? What's your job?

My hibernate Properties are as follows (if it helps):

hibernate.connection.driver_class =com.MysqL.jdbc.Driver
hibernate.dialect =org.hibernate.dialect.MysqLDialect
hibernate.connection.url =jdbc:MysqL://localhost/dbdbdbdbdb
hibernate.connection.username=root
hibernate.connection.password=password
hibernate.connection.pool_size=10
jdbc.batch_size=30
hibernate.show_sql=true
hibernate.current_session_context_class=true
hibernate.hbm2ddl.auto=validate
hibernate.cglib.use_reflection_optimizer=false
hibernate.generate_statistics=true
hibernate.cache.use_query_cache=true
hibernate.cache.region.factory_class=net.sf.ehcache.hibernate.EhCacheRegionFactory

Solution

All right, scam call the police! This is a real problem with eclipse Tomcat integration Before the HBM file takes effect, I must clean up the Tomcat directory and republish it

Tip: if you are running ant in eclipse, be sure to refresh the eclipse workspace from time to time Try to learn something

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>