-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: Hbm2Java: SuperClass support to avoid merge? (EOGenerator)
PostPosted: Wed Feb 04, 2004 2:54 pm 
Newbie

Joined: Thu Jan 22, 2004 5:52 pm
Posts: 6
Location: Xalapa, Ver, Mexico
Hi!
Lets say I have an hbm like this:

<class
name="mx.lania.extranet.domainmode.Group"
table="groups"
>
<id
name="id"
type="int"
column="id"
>
<generator class="sequence">
<param name="sequence">group_id_seq</param>
</generator>
</id>
<property
name="name"
type="java.lang.String"
column="name"
not-null="true"
length="50"
/>

</class>

It will normally generate a somewhat class like this:

public class Group implements Serializable {

public Group() {
}

public java.lang.Integer getId() {
return this.id;
}

public void setId(java.lang.Integer id) {
this.id = id;
}

public java.lang.String getName() {
return this.name;
}

public void setName(java.lang.String value) {
this.name =value;
}
}

but I want it to generate 2 class, one with de persisten propeties (an or relationships) and another, for me to write my particular bussines logic:

//In SuperGroup.java
public class SuperGroup implements Serializable {

public BaseGroup() {
}

public java.lang.Integer getId() {
return this.id;
}

public void setId(java.lang.Integer id) {
this.id = id;
}

public java.lang.String getName() {
return this.name;
}

public void setName(java.lang.String value) {
this.name =value;
}
}

//In Group.java
public class Group extends SuperGroup {
}

This way, i can regenerate my .java very every time that i feel like it
without the risk of loosing my custom bussines logic (yes, I know i can marge, and restore old CVS versions of my work, but this way it would be SO much easier, I miss http://www.rubicode.com/Software/EOGenerator/ from my EOF times) if this is not supported I think i shouldt be so hard to do it, if someone gives me some hits about what classes/methods in hbm2java i have to modify I'd be glad to contribute this back to the community.
bye
Luxspes


Top
 Profile  
 
 Post subject: In EOGenerator they explain this better
PostPosted: Wed Feb 04, 2004 2:58 pm 
Newbie

Joined: Thu Jan 22, 2004 5:52 pm
Posts: 6
Location: Xalapa, Ver, Mexico
EOGenerator is a command-line tool for generating Java and Objective-C EO classes from EOModel file(s) using a different method than Apple's EOModeler. Two classes are generated for each EOEntity: one that is generated every time the EOEntity changes, and a subclass (the real EO class) that is only generated once. This approach allows business logic to be implemented in the subclass without fear of being overwritten later.

When using customized templates, it is possible (among other things) to generate methods to call fetch specifications, generate methods to add and remove objects from relationships with typed arguments, to have a custom superclass for all your EOs, and generate cross-framework #import statements correctly for Objective-C classes when models are in separate frameworks. Example templates are provided for Java and Objective-C that show some of these additional abilities.

EOGenerator can be compiled and used on MacOS X 10.x, MacOS X Server 1.2, WebObjects/NT, and OPENSTEP. It comes with source code. EOF or WebObjects is also required.

Is something like this possible with hbm2java?
bye, thanks
Luxspes


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 04, 2004 4:25 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
geezz...people just don't read the docs ;(

This is the THIRD time today i say the following:

Read the docs about the meta tag in the docs.

Look at <meta attribute="generated-class"> which allows exactly this.

You only add it on a "need-to-extend" basis....avoiding extra classes if not needed.

You then just make it generate an abstract calss which you extend...

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Sorry generated-class overrule the name of the actual class
PostPosted: Wed Feb 04, 2004 5:55 pm 
Newbie

Joined: Thu Jan 22, 2004 5:52 pm
Posts: 6
Location: Xalapa, Ver, Mexico
Yes, it is in Page 126 in the hibernate_reference.pdf it says:
generated-class
generated-class overrule the name of the actual class generated
I am sorry, I just i didn't think that I could use it for this... on the other side th disadvantage is that i use MiddleGen to generate de .hbm, and I am going to have to customize them by hand (it would be nice to be able to do this automagically ;)
bye
Luxspes


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 04, 2004 6:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
don't the new middlegen support arbitrary meta tags on stuff, or is it just a few specifics it knows ?

David ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: XDoclet
PostPosted: Wed Feb 04, 2004 6:35 pm 
Newbie

Joined: Thu Jan 22, 2004 5:52 pm
Posts: 6
Location: Xalapa, Ver, Mexico
Hi!
"From release 3 of the plugin XDoclet markup can be generated using meta tags in the hbm mapping document." (http://www.hibernate.org/98.html) but I found nothing about the metatag that I need :'(
Anyone working on this?
bye
Luxspes


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.