Book a Demo

Author Topic: Java / Hibernate Classes  (Read 5037 times)

andrewb

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
  • hmmm...
    • View Profile
Java / Hibernate Classes
« on: October 30, 2005, 07:28:24 pm »
Hi all,

I'm just completing design of a logical data model for a Java system that will use Hibernate as a data communication layer (please excuse any semantic errors as I am a BA rather than a developer!).

I can generate the Java classes quite easily using the Source Code Engineering function, however the hibernate code also follows a fairly standard algorithm and, if possible, I would like to add the required statements into the classes.

Could anyone give me some basic instruction on how I'd go about changing the config files so as to achieve this?

Regards,

Andrew

thomaskilian

  • Guest
Re: Java / Hibernate Classes
« Reply #1 on: October 31, 2005, 02:58:47 am »
- Open the class properties. Goto Detail/Operations.
- (Or double click the appropriate Operation in the Project View.)
- Click the Behaviour tab.
- Enter the code in Initial Code

If you create new methods, first save the name in the General tab. Then add parameters and the initial code.

When you generate code, you probably should opt for Replace in the Advanced Options.

casper

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Java / Hibernate Classes
« Reply #2 on: October 31, 2005, 04:58:42 am »
Correct me if I'm wrong but I think that isn't very suitable. As a .NET nHibernate developer I would choose an other option.  

I would insert the Hibernate code in the code generation template of Java. This is done by clicking on the Menu 'Configuration' and select 'Code Generation Templates'. After that a window pops up, select Java as Language.
These templates convert the model to Java code. So whit a liltle effort you could add the hibernate code to it. This way you dont have to repeat the proces of filling in the hibernate code into the classes. The proces would be automated by the templates.

Even beter would be to concider hibernate as a different platform than Java. This way you'
re development would be more model driven. Offcourse it takes some time to addept the whole MDA type of developing. But I can tell you, it's worth it.

thomaskilian

  • Guest
Re: Java / Hibernate Classes
« Reply #3 on: October 31, 2005, 05:26:16 am »
You're probably right for I don't have any fundamental Java background.

andrewb

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
  • hmmm...
    • View Profile
Re: Java / Hibernate Classes
« Reply #4 on: November 01, 2005, 02:16:30 pm »
Thanks for your help - most appreciated.

beaf

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Java / Hibernate Classes
« Reply #5 on: December 11, 2005, 05:24:18 pm »
I don't suppose anyone has any Java_Code_Template.xml for Hibernate generation available do they? And has anyone done a dedicated Hibernate language template? I am looking for potentially a hibernate mapping file (.xml) code generator before I start looking at writing one myself - and look at the time...1.30am!