-->
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.  [ 5 posts ] 
Author Message
 Post subject: Q on Controlling POJO generation
PostPosted: Sun Feb 04, 2007 6:31 pm 
Beginner
Beginner

Joined: Fri Jan 26, 2007 3:16 pm
Posts: 24
Hi, I'm reading the hibernate_tools.pdf Chp. 6 "Controlling POJO Code Generation".

I understand the use of the meta tag, etc, but I use the Eclipse plugin to generate both the hbm.xml files and the domain classes.

I'm not sure where I should put
Code:
<meta> </meta>
tags.

If I put them in SomeDomainClass.hbm.xml it gets overwritten when I use the plugin.

If I don't choose the hbm.xml exporter, and only choose the domain code generation exporter, and put meta tags in the SomeDomainClass.hbm.xml file...when I re-run, I don't see it take effect.

E.g. I added the following tag:

Code:
<class etc..>
  <meta attribute="implements">SomeInterface</meta>
etc...
</class>


If I re-run, SomeDomainClass still does not implement SomeInterface.

I tried also adding it to Globals.hbm.xml that does not get generated by the Exporter, but still no luck?

How can I affect POJO generation with the Eclipse plugin?

Thx in advance,
Davis


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 05, 2007 9:33 am 
Beginner
Beginner

Joined: Fri Jan 26, 2007 3:16 pm
Posts: 24
Ok, answering my own question here, which actually spawned a few new questions.

In hibernate.reveng.xml I tried:

Code:
<table name="SOMETABLE">
  <column name=" ...etc...
  <meta attribute="extends">some.package.MyAbstractClass</meta>
etc..


but the DTD complains about this...

Quote:
The content of element type "table" must match "(meta*,primary-key?,column*,foreign-key*)".


Why is this?

So, I moved it up to table-filter like so:

Code:
<table-filter match-name="SOMETABLE">
   <meta attribute="extends">some.package.MyAbstractClass</meta>
</table-filter>


...and this works.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 05, 2007 12:44 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you need to follow the DTD; nothing special about it.

Code:
<table name="SOMETABLE">
  <meta attribute="extends">some.package.MyAbstractClass</meta>    <column name=" ...etc...


will work. Just as the DTD states ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 06, 2007 9:09 am 
Beginner
Beginner

Joined: Fri Jan 26, 2007 3:16 pm
Posts: 24
max wrote:
you need to follow the DTD; nothing special about it.

Code:
<table name="SOMETABLE">
  <meta attribute="extends">some.package.MyAbstractClass</meta>    <column name=" ...etc...


will work. Just as the DTD states ;)


Max -- my error...you are correct. Missed the explicit ordering of the DTD.

A follow-up question, though. I want to assign my own Comparator. Consider I have the following entry in hibernate.reveng.xml

Code:
   <table name="SHAPE">
      <column name="EDGE_ID" type="long" property="edgeId"></column>
      <column name="SEQNR" type="int" property="seqNumber"></column>
      <column name="FYSPKEY" type="int" property="shapeFysKey"></column>
      <column name="X" type="int" property="x"></column>
      <column name="Y" type="int" property="y"></column>
      <column name="Z" type="int" property="z" exclude="true"></column>
      <foreign-key constraint-name="XFKSHAPE_EDGE" foreign-table="EDGE">
         <column-ref local-column="EDGE_ID" foreign-column="EDGE_ID" />
         <column-ref local-column="FYSPKEY" foreign-column="FYSPKEY" />
         <many-to-one property="edge" />
      </foreign-key>      
   </table>


In the Edge.java class, then this creates:

Code:
    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "edge")
    public Set<Shape> getShapes() {
   return this.shapes;
    }


which is almost what I want. What I really want is either a List or a SortedSet that sorts based on the SEQNR column. I can build my own Comparator that does this after the fetch, but it seems more logical to store it as a SortedSet or a List here. I can't seem to figure out how to instrument this via hibernate.reveng.xml. Any suggestions on how I might do this?

Thx in advance,
Davis[/i]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 08, 2007 5:29 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
its not supported when reverse engineering

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.