facebook

Hibernate full schema generation

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #212431 Reply

    Dave S-B
    Member

    I’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.

    #212454 Reply

    Riyad Kalla
    Member

    Dave,
    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?

    #212469 Reply

    snpe
    Member

    Rkalla,
    There is nothing about hibernate in help

    Dave,
    You can try select all tables and call hibernate mapping, but I think that You need middlegen

    regards

    #212489 Reply

    support-jeff
    Member

    No 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.

    #212508 Reply

    snpe
    Member

    I 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 explorer

    I 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

    #212517 Reply

    Dave S-B
    Member

    OK – 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…

    #213112 Reply

    support-jeff
    Member

    snpe –
    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.

    #213117 Reply

    snpe
    Member

    Jeff,
    I can’t do it in old project with hibernate.
    I make new project and edit .myhibernatedata like this new project and it work

    I wait for other func 🙂

    regards

    #224952 Reply

    jason poley
    Member

    toolset 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.

    #224955 Reply

    support-jeff
    Member

    Where 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.

Viewing 10 posts - 1 through 10 (of 10 total)
Reply To: Hibernate full schema generation

You must be logged in to post in the forum log in