facebook

Hibernate tools code generation question

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #245113 Reply

    fabio
    Participant

    HEllo and thanks in advice.

    ‘ve generated hibernate mapping file and code form db perspective.
    All ok.
    After i modified the mapping file.

    Are there any way to regenerate just the java code from the hibernate mapping file.

    I?m running 4.1 ga on xp sp2.

    Fabio

    #245116 Reply

    @fabiob@taipan.it wrote:

    Are there any way to regenerate just the java code from the hibernate mapping file.

    While you created the mapping file, there was the option to create a “reverse engineering file” (hibernate.reveng.xml).

    Try to create this file and edit that one. Then, you can simply use “Create Hibernate mapping” again.

    Note: I had some problems with this when I tried it the first time. For some reason, the XML wasn’t updated when I changed something in the mapping wizard.

    Do this to check if it works for you: Open the XML file in the MyEclipse XML Editor and keep it open when you start the mapping wizard in the context menu. Now, whenever you give a field a special type/name/whatever, you should see this show up in the XML editor as soon as you select a different field.

    If this doesn’t happen, then the updating of the file doesn’t work for some reason (nothing in the error log, either).

    Hope this helps,

    #245117 Reply

    Brian Fernandes
    Moderator

    Fabio,

    Sure, you can do the same thing as you did before to generate the mappings, but make sure you only check the generation options you require in the wizard.

    Generating the POJOs from the mapping file directly is something that is not yet possible, but we’re looking into it.

    Best,
    Brian.

    #245118 Reply

    Brian Fernandes
    Moderator

    Aaron,

    The moment you try to customize the mapping process a file called hibernate.reveng.xml will be created for you *automatically* if one does not exist. If it does exist it will be loaded and the wizard will be populated with values gained from the file.
    If you wish, you can always create this file manually (with a name of your choice) and link to it on the second page of the wizard.

    Keeping the reveng file open in the XML editor is not necessary for the file to be updated, it will update even when closed and will be used for the mapping. If it did not work for you, we can follow up and see what went wrong.

    The reveng file does allow you to customize the mapping process, but otherwise it does not help in anyway to “generate only the java classes” – you can do that only from the RE wizard’s main page. As sated above, generation directly from a .hbm.xml file is not supported yet.

    Best,
    Brian.

    #245119 Reply

    fabio
    Participant

    Hy digulla tahanks for your helo.
    if i redo the generation, also with the rev-eng file
    it seems that all mapping are overwritten again.
    IN the reveng… i can see all the applied operations, but i can’t re-use existing mapping file.

    Fabio

    #245120 Reply

    Brian Fernandes
    Moderator

    Fabio,

    The hibernate.reveng.xml file does not affect what files are generated.
    When you invoke the reverse engineering wizard, uncheck the first checkbox which says “Hibernate mapping file (*.hbm.xml) for each database table”. The mapping files will not be overwritten.

    Please note that changes you made in your mapping file will not be picked up in the POJO generation, as the process will still take information directly from the database. This is a feature we are working on.

    Best,
    Brian.

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: Hibernate tools code generation question

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