- This topic has 9 replies, 5 voices, and was last updated 19 years, 10 months ago by support-jeff.
-
AuthorPosts
-
Dave S-BMemberI’ve just got the latest MyEclipse and wanted to quickly try out Hibernate. Up to now I’ve been using OJB from the Jakarta mob and this has a very handy tool called reverse-db that will create a mapping file and java classes based on an existing database. I was hoping the MyEclipse plugin for Hibernate would do something similar, but I can only see the option to create mapping files for individual tables. Is there a way of generating files for a whole schema (or selected tables)?
The time-saver for me with OJB is the auto-generation of java classes and mapping files which include not only the basic properties (i.e. the database fields) but also nested collections (i.e. the relationships). OJB also has some nice features for many-to-many relationships which keep the inevitable indirection tables out of your java code.
Riyad KallaMemberDave,
If you click on Help > Contents there is an entire help set dedicated to explainin the Hibernate tooling and what it can do, maybe this would help?
snpeMemberRkalla,
There is nothing about hibernate in helpDave,
You can try select all tables and call hibernate mapping, but I think that You need middlegenregards
support-jeffMemberNo middlegen needed – not sure where you are getting that?
In the Database Explorer, configure a new connection profile (add new drivers in preferences if necessary), open the connection, browse tree down to tables and select all the tables shown – right-click and select “Create Hibernate Mapping” – follow the wizard and all your tables will be mapped.
Hope this helps. Documentation is lagging but on its way.
snpeMemberI know it – but with middlegen I can change mapping (change base class for every tables, change type for arbitrary columns), add hibernate metadata,
add or remove collections etc.There is HibernateSynchronizer,too – it is better, but it haven’t jdbc explorerI use midllegen, currently and “manual” hibernate-tools for create .java
I can set MyEclipse with new project (when myeclipse create hibernate.cfg.xml), but can’t with old project with hivernate libraries and configuration – MyEclipse return error for hibernate.cfg.xml (ME seek cfg file in /hibernate.cfg.xml – I set properties for hibernate in project, but without success)
regards
Dave S-BMemberOK – I’ve got the multiple table mapping to work (must have been something odd going on before). It is a shame that the relationships aren’t mapped as well as the fields – with large databases this means a lot of work to put all the related collections in. We’re just finishing a project where the database consists of 123 tables. The data is complex and there’s many levels of relationships between the tables (on average, each table will link to 3 or 4 others). We used OJB. With a database of this size and complexity it took about an hour with OJB’s reverse-db tool (and a good knowledge of the database) to create the mapping file and all the java classes (and that gave us a fully operational DAO layer, albeit without any validation or business logic). I dread to think how long it would take to manually add in all the relationships to the Hibernate generated classes…
support-jeffMembersnpe –
You need to move hibernate.cfg.xml under your src directory (wherever that is) and adjust the location in the property view accordingly.
As for other functionality, you just wait. We have more in store…. 😉davesb –
Not exactly sure what you are having difficulty with – the Hibernate mapping export or the DB visualizer tool (well hidden in DE since it is not too good)? If the latter, you are on your own. If the former, as long as your database has foreign key constraints defined, simple many-to-one relationships should be created for you automatically (but not more complex collections or many-to-many…yet). If they are not, please give me more details – database, version, and DDL would be useful.
snpeMemberJeff,
I can’t do it in old project with hibernate.
I make new project and edit .myhibernatedata like this new project and it workI wait for other func 🙂
regards
jason poleyMembertoolset question,
i can’t seem to auto gen hibernate from multiple dbs, since its complaining that it couldn’t “create” a hibernate.cfg.xml file… (when it existed) so i moved it, and there is no hibernate.cfg.xml and its still complaining that it can’t create it. any hints? is it cached somewhere? (i have already looked for file and restarted eclipse, refreshed …etc)i am sure i am missing something but would appreciate some guidance…
thanks in advance.
support-jeffMemberWhere was the config file in your project structure – in the source directory? Had you moved it prior to trying to create mappings? Please post the content of the .myhibernatedata file in the root of your project, and any error logs in the eclipse .log file related to the Hibernate tools.
-
AuthorPosts