You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.
When using MS Sql Server or MySQL database servers, for example, it is possible that the primary key of your table is an identity column and thus auto-generated (i.e. auto-incremented during insert transactions).
When using seam-gen (or more specifically hbm2java tool via 'seam generate-entities' cmd line command), your resulting reverse engineered JPA entity class will not have a @GeneratedValue annotation by default.
In order to better handle this situation so you don't have to manually modify the constructors and add the @GeneratedValue yourself post-revengr process, try the following:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering SYSTEM "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >
<hibernate-reverse-engineering>
<!-- This file is intentionally generated empty by seam-gen -->
<!-- You can add any filtering/setup you want for your app -->
<!-- do not include EquipmentRecovery.sys.* objects from sys schema! -->
<schema-selection match-schema="dbo"/>
<table catalog="EquipmentRecovery"
schema="dbo"
name="ApplicationPermission">
<primary-key>
<generator class="identity"/>
</primary-key>
</table>
<table catalog="EquipmentRecovery"
schema="dbo"
name="ApplicationRole">
<primary-key>
<generator class="identity"/>
</primary-key>
</table>
<table catalog="EquipmentRecovery"
schema="dbo"
name="ApplicationSetting">
<primary-key>
<generator class="identity"/>
</primary-key>
</table>
<table catalog="EquipmentRecovery"
schema="dbo"
name="ApplicationSettingChangeLog">
<primary-key>
<generator class="identity"/>
</primary-key>
</table>
<!-- you get the idea! -->
</hibernate-reverse-engineering>
Refer to the following section of the Hibernate Tools doc: My Link
Refer to this thread in Hibernate forum regarding this topic: My Link
It would be nice if hbm2java was able to auto-matically include these modifications/additions to our JPA entity classes without our explicit instructions (i.e. if hbm2java detects via the JDBC driver's database metadata info that the PK is an identity column with identity seed, then modify the constructors appropriately and add the @GeneratedValue annotation to the PK getter method).
Refer to the following section of the Hibernate Tools doc for more details on how to achieve this. According to Max Anderson in the thread above, it requires a custom implementation of org.hibernate.cfg.reveng.dialect.MetaDataDialect interface.
6.4. Custom Database Metadata By default the reverse engineering is performed by reading using the JDBC database metadata API. This is done via the class org.hibernate.cfg.reveng.dialect.JDBCMetaDataDialect which is an implementation of org.hibernate.cfg.reveng.dialect.MetaDataDialect. The default implementation can be replaced with an alternative implementation by setting the property hibernatetool.metadatadialect to a fully qualified classname for a class that implements JDBCMetaDataDialect. This can be used to provide database specific optimized metadata reading. If you create an optimized/better metadata reading for your database it will be a very welcome contribution.
I've gone through the whole post and found it so informative exactly upon my liking, This is a wonderful blog it has almost every thing in it, Thanks a lot for sharing! Free Cell Phone Spy
I just didn't know. I am glad to see that people are actually writing about this issue in such a smart way, showing us all different sides to it. You are a great blogger. Please keep it up. I cant wait to read whats next.
Clubmz espy
This looks absolutely perfect. All these tinny details are made with lot of background knowledge. I like it a lot. This was a useful post and I think it is rather easy to see from the other comments as well that this post is well written and useful.skin moles
I hope it will work well when I apply your program.
regards,
<a href="http://blogskinny.com">Leigh Gabbett</a>
Do they all they come under MySQL. I am currently learning it and i am beginning stage.I feel these will useful in later stages of my course. regards, JCody Hugar
You helped me a lot indeed and reading this your article I have found many new and useful information about this subject. Posicionamiento web
Wow, awesome blog structure! How lengthy have you ever been blogging for? you make running a blog look easy. The entire glance of your web site is wonderful, neatly as} the content! How To Remove Skin Tags
What an amazing content is this and surely it makes realize each and everyone who read this. Thanks for providing so fantastic and sweet suggestions ....i really appreciate it.A1 Web Directory
So many informative post to read here thanks for everything guys. Las Vegas Hotels
What I want to know is why you didnt think to include the other side of this issue ? There are so many things that youre missing here that I dont see how you could actually form an intelligent opinion on the subject. Its like you didnt even consider that there me be another side here love quotes
I am so thankful to have this page thanks for sharing me your link.007 Las Vegas hotels
I never seen a site like this before, anyway this page is so cool not boring. Vegas hotel Rooms
Sometimes, we end up dieting (crash diets, that is) and then the tendency is we don’t really eliminate the problem. What then can be the solution to the problem?
Fat burnersI did a site for storage auctions that required javascript, and it was really a chore! Thanks for the advice.
Thanks for the unmatchable diary.it was rale useful for me.navigator sharing specified ideas in the instant as symptomless.this was actually what i was labour for,and i am voluntary to came here!
Cheap LED TubeUseful post. thanks for the modified constructors and the @Generated Value for post-revengr process, the above listed are much helpful and works with me.- jinghenews
Blogs are good for every one where we get lots of information for any topics nice job keep it up !!! Help With Essay Writing
Good article and a summation of the problem of Nice. My only problem with the analysis is given that much of the population has joined the chorus of mythology proposed deregulation interest is inclined towards the perpetuation of the current system and given the lack of a popular cheerleader for your arguments, I do not see much in the way of change. Essay Writing Service Buy An Essay Dissertation Help
There is definitely a big demand in this area. I think people really need to take advantage of this. DO not pass this up. twitter layouts
.I enjoy any tips a person offer inside your posts I am just fairly specified I’ll study a lot of brand new information at this point! All the best ! for the following! comparateur prix