-->
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: Filter the entities to be generated in a multi-modules proje
PostPosted: Sat Nov 10, 2007 7:41 pm 
Newbie

Joined: Wed Jan 28, 2004 11:33 am
Posts: 4
Hi,

I am trying to setup a project with several modules.
Each module will define its own entities using a set of hbm files with dependencies between modules.

ex:
1) User module defines the User entity
2) Forum module defines Post entity which will depend on User module as each Post reference a User.

The build of each module will process the hbm files specific to the module to generate the entities defined in this module.

Given that the generation tool needs the definition of the entire schema, the mappings of the external entities referenced by the module entities need also to be included in hibernate.cfg.xml.

Then the hbm2java task generates all the entities... even thoses of the external module (ex: Post and User whereas User is already processed in its module).

Is there a way to restrict/filter the entities to be generated during a hbm2java task run?

Thanks for your help!
Adalbert


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 11, 2007 5:41 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
No not currently - but it's in jira as a feature request.

Workaround:
Generate
and then move/delete the things that you don't want.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 11, 2007 3:21 pm 
Newbie

Joined: Wed Jan 28, 2004 11:33 am
Posts: 4
Thanks max,
I was thinking to add an "exclude" option/tag on the "hibernatetool" task tag.
The content would be entities names (including packages) with wildcards.

For example
Code:
      <hibernatetool destdir="${source.generated}">
         <classpath>
            <pathelement location="${libraries}"/>
            <pathelement location="${compile.target.dir}"/>
            <pathelement location="${install.interal.mapping.dir}"/>
         </classpath>
         <configuration configurationfile="${etc.dir}/hibernate.cfg.xml"/>
         <exclude name="foo.bar.Toto foo.bar.sub.*"
         <hbm2java/>
      </hibernatetool>

Do you think this is a good approach or would you have a better suggestion?
Thanks,
Adalbert


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 12, 2007 7:30 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
it is a good approach and along the lines that I'm considering.

Points to consider:

It is not just entities that should/could be filtered; its also tables for e.g. hbm2ddl or both for hbm2doc.

The filter should be possible to define globally, but also locally per exporter since each exporter can have their own foreach attribute set.

Try and mimick ant resource collection/electors/filesets mechanism to make it more "natural"

...and finally, what is the filter on ? Is the filter on the input or the output ?
e.g. hbm2java process entities in the hbm model, and outputs the pojo for this entity - but it could be generating other things. I think the filter should be on the input; e.g. filtering the entities, components, tables etc.

One possible way of handling theses could be:

Code:
<hibernatetool destdir="${source.generated}">
         <classpath>
            <pathelement location="${libraries}"/>
            <pathelement location="${compile.target.dir}"/>
            <pathelement location="${install.interal.mapping.dir}"/>
         </classpath>
         <configuration configurationfile="${etc.dir}/hibernate.cfg.xml"/>


             <filter> <!-- filter is not a good name since it means a different thing under ant, maybe restrict? -->
                  <table name="CUST.*"/>
                  <entity name="org.model.*"/>
            </filter>
         <hbm2java>
                  <filter>
                       <entity name=".*.customer.*"/> <!-- only the customer part of the model -->
                  </filter>
          </hbm2java>
      </hibernatetool>


The filters would be chained and be available inside the templates to be able to do filtering from more customized templates.

Thoughts?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 03, 2008 11:58 am 
Newbie

Joined: Mon Mar 05, 2007 2:25 am
Posts: 12
This would also solve my problem. I want to generate the class specified in the root of my hbm, but not the component class in that same HBM. Do for me a filter on the output would probably work better.


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.