- This topic has 19 replies, 6 voices, and was last updated 20 years, 5 months ago by
tarantula.
-
AuthorPosts
-
Stephen SmithParticipantDoes anyone have a brief example of how to use the Hibernate wizard in the 3.8GA version? It’s not self-obvious to me, even after attempting to read through a lot of the Hibernate ‘getting started’ docs.
Thanks
Riyad KallaMemberHelp > Contents, and then click on “MyEclipse Database Explorer User guide” should get you started 😉
Stephen SmithParticipantI’m also wondering about the comment in the ‘hibernate.cfg.xml’ file which says: “Do not edit: this is a generated file that is synchonized by MyEclipse Hibernate tool integration”.
What do you have to do to a java source file in order to get it recognized by the Hibernate integration and generate the appropriate mapping file and include it in the cfg file?
Riyad KallaMemberI believe the typical order of operations is a) add Hibernate caps then b) Use the DB browser to generate hibernate mappings from the tables in your DB… the tool will sync up everything for you.
support-jeffMemberBut only if you check the box to specifically update the config file. This check box is unchecked by default now; next maintenance release it will be checked by default.
Riyad KallaMemberAhh good catch,thanks Jeff.
snpeMemberJeff,
Why You use hibernate.cfg.xml with ddl2hbm mapping – I don’t understand ?
If You wantt add mapping files in cfg it isn’t really important – I think that is the best use hibernate with spring and then is this unnecesseryregards
support-jeffMembersnpe –
I do not follow your response:Why You use hibernate.cfg.xml with ddl2hbm mapping – I don’t understand ?
We no longer use the ddl2hbm mapping tool. We use a custom Velocity based mapping tool.
If You wantt add mapping files in cfg it isn’t really important – I think that is the best use hibernate with spring and then is this unnecessery
It is very important to add mapping files to the config – the Hibernate Tool in ME creates a SessionFactory class for you that configures Hibernate using the XML file. You have the option of doing this manually if you wish – but you are on your own then. As for Spring support, there is the possibility that this will be added eventually (if I have anything to say about it 😉 at which point we would definitely want to support adding the mappings to the spring config file as well.
tarantulaParticipant@support-rkalla wrote:
I believe the typical order of operations is a) add Hibernate caps then b) Use the DB browser to generate hibernate mappings from the tables in your DB… the tool will sync up everything for you.
Hi there,
I am using MyEclipse version 3.7.200 with Eclipse 3.0 Build 200406251208. I read the MyEclipse Database Explorer User Guide and I understand how the database explorer perspective works (eg. exporting tables via Hibernate) but I have a question about the Hibernate wizard and the order of operations you suggest.
When I first add Hibernate capabilities to a project, I am prompted to create a new hibernate.cfg.xml file and I select the database connection I want. So far so good. I noticed there is a tab for selecting the mapping files I want to add to the hibernate.cfg.xml file but following the steps above I wouldn’t have any mapping files in my project yet.
Also, the database explorer perspective does not allow me to export tables and create mapping files until I have added the Hibernate caps to my project. This looks like a catch-22. Do I have to add the mapping files manually to the main config file or is there another way to do this using MyEclipse?
Thank you,
tarantula
support-jeffMemberNo catch-22. The add mappings section of the Add Hibernate Caps/Configuration wizards is for projects that already contain mappings. Most folks creating a new project won’t have any, of course. The Export thru Hibernate feature of DB Explorer automatically will add the mappings created to the config file for you as of ME 3.8 GA – so you need to upgrade if you want this feature.
brianiMemberIs the MyEclipse´s hbm generator able to generate one-to-many relationships?
support-jeffMemberNot yet. Just many-to-one (i.e. your typical foreign key relationship in a db). one-to-many will be coming in a future release. For now you can hack the mapping and add inverse to the many-to-one to refer to a one-to-many you can put in the related class. follow?
tarantulaParticipantJeff,
Thanks for the tip. I upgraded to 3.8.1 and the table-to-code generation works much better. You suggest hacking the mapping files to express different relationships (eg. one-to-many, one-to-one, etc.). Could I use XDoclet to do this?
tarantula
support-jeffMemberThat is fine. Just be aware that (1) xdoclet is not used in the Hibernate tool to do the generation and (2) regeneration will whack your changes to the mapping and abstract base class.
snpeMemberJeff,
xdoclet is used for generate mapping files (hbm) from java (not for ddl to hbm) – You can make xdoclet tags when generate java from xbm
There is xdoclet hibernate modulregards
-
AuthorPosts