Help

Switch Workspace

Built with Seam

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.
21 comments:
 
10. Sep 2011, 03:02 America/New_York | Link

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

 
26. Sep 2011, 05:33 America/New_York | Link

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

 
20. Dec 2011, 02:11 America/New_York | Link

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

 
27. Dec 2011, 16:20 America/New_York | Link
Oh this tutorial seems to reduce a work a little.If we had to them manually would take an extra time.
I hope it will work well when I apply your program.
regards,
<a href="http://blogskinny.com">Leigh Gabbett</a>
 
27. Dec 2011, 16:25 America/New_York | Link

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

 
28. Dec 2011, 23:00 America/New_York | Link

You helped me a lot indeed and reading this your article I have found many new and useful information about this subject. Posicionamiento web

 
29. Dec 2011, 07:53 America/New_York | Link

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

07. Jan 2012, 11:09 America/New_York | Link

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

08. Jan 2012, 12:03 America/New_York | Link

So many informative post to read here thanks for everything guys. Las Vegas Hotels

 
09. Jan 2012, 11:06 America/New_York | Link

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

 
10. Jan 2012, 05:15 America/New_York | Link

I am so thankful to have this page thanks for sharing me your link.007 Las Vegas hotels

 
12. Jan 2012, 10:27 America/New_York | Link

I never seen a site like this before, anyway this page is so cool not boring. Vegas hotel Rooms

12. Jan 2012, 13:45 America/New_York | Link

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 burners
 
15. Jan 2012, 18:57 America/New_York | Link

I did a site for storage auctions that required javascript, and it was really a chore! Thanks for the advice.

 
17. Jan 2012, 02:27 America/New_York | Link

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 Tube
 
17. Jan 2012, 07:54 America/New_York | Link

Useful 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

 
18. Jan 2012, 00:40 America/New_York | Link

Blogs are good for every one where we get lots of information for any topics nice job keep it up !!! Help With Essay Writing

 
18. Jan 2012, 08:20 America/New_York | Link

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

18. Jan 2012, 10:19 America/New_York | Link
I don't know what to say. This blog is fantastic. That's not really a really huge statement, but its all I could come up with after reading this. You know so much about this subject. So much so that you made me want to learn more about it. Your blog is my stepping stone, my friend. Thanks for the heads up on this subject. ekg technician courses
 
26. Jan 2012, 08:42 America/New_York | Link

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

 
26. Jan 2012, 10:15 America/New_York | Link

.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