Generate Hibernate Mapping File
Hi,
I'm currently digging myself into IDEA's Hibernate support. What I ultimately want to do, is to design a persistence model in an ER diagram and have a hibernate mapping file created accordingly.
So far I've added the Hibernate Facet to the project, created a Hibernate configuration file in the Module Settings and added a mapping file under the configuration file in the J2EE view. When I now open the ER diagram and add entities to it, the classes are generated with JPA annotations and nothing is done to the mapping file. What do I need to do so that IDEA populates the mapping file and doesn't create JPA annotations. This is with IDEA 8.
Thanks
-Tim
Please sign in to leave a comment.
Hello Tim,
Please, try "New Hibernate class" instead of "New Entity".
Alexander.
Hello
I discovered that IDEA 8.1 can generate class mapping with no id or composite-id tags (especially if you don't have any primary keys in your table). It will generate parse errors. You must then configure id yourself as hibernate requires it.
Hello Jan,
This is true.
What would you expect IDEA to do for you in this case?
I can think of making the first column an id column or add generated
]]> definition.
Gregory Shrago
Jan wrote:
Hello Gregory,
It's hard to come up with identity if there is none in the table,isn't it?
My intention was not to point out a bug in IDEA (as there clearly isn't any in this matter), but rather to explain why there are parse errors for generated XML files.
What I can suggest is perhaps to generate empty 'id' tag, maybe with a XML comment above, that IDEA couldn't find any primary keys in the table (as it happens in poorly designed table schemas). It would get rid of the parse errors, and give some explanations to the developer.
Regards,
Jan
BTW: I think have posted my explanation to the wrong thread. Sorry about that.