You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by phillip rhodes <rh...@yahoo.com> on 2005/05/25 20:26:56 UTC

Reuse of hibernate domain objects in multiple maven projects?

I have a core project that encapsulates some domain
objects that I reuse in many of my projects. Many of
the domain objects use hibernate to be persisted.  I
use the xdoclet and hibernate plugins to generate the
mapping files and create the tables in a schema.

I reuse these core object relational mappings in many
other projects.  Each project has its own schema, so I
need to create these core tables in each of the other
schemas.  

So far, I have been copying the class files and
mapping files to each of these projects using a custom
maven plugin and running the hibernate:schema-export
goal for that individual project so that all the
necessary tables are created.  I need to copy the
class files over or the hibernate plugin will not
work.

While this works, I was interested in hearing how
other folks have dealt with using the hibernate goals
for a shared set of core objects across multiple
projects?

A couple of drawbacks is that since I copy the class
and hbm files to my new projects, I am getting
unwanted classes in my new pom jar file (i would
rather just get the class file from the core project).
Another drawback (minor) is the time required to
regenerate the ddl from the mappings when this has
already been done in the core project.


Interested in hearing your thoughts.
Thanks.







---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Reuse of hibernate domain objects in multiple maven projects?

Posted by Kristian Nordal <kr...@gmail.com>.
Hi,

On 5/26/05, phillip rhodes <rh...@yahoo.com> wrote:
> 
> I have a core project that encapsulates some domain
> objects that I reuse in many of my projects. Many of
> the domain objects use hibernate to be persisted.  I
> use the xdoclet and hibernate plugins to generate the
> mapping files and create the tables in a schema.
> 
> I reuse these core object relational mappings in many
> other projects.  Each project has its own schema, so I
> need to create these core tables in each of the other
> schemas.

Maybe I don't understand what you want to do, but this sounds more
like a Hibernate problem than a Maven problem. I have projects with
domain objects that are persisted with Hibernate, and reuse these
projects in many other projects. I define all mapping files that are
used in each project in that projects hibernate.cfg.xml (<mapping
resource="..."/>).

> So far, I have been copying the class files and
> mapping files to each of these projects using a custom
> maven plugin and running the hibernate:schema-export
> goal for that individual project so that all the
> necessary tables are created.  I need to copy the
> class files over or the hibernate plugin will not
> work.

I haven't tried any Hibernate plugins, but running
org.hibernate.tool.hbm2ddl.SchemaExport with the option
--config=".../hibernate.cfg.xml will generate your schema with all
tables (as long as you have defined all the necassery mapping
resources in the config and all the dependencies are in the
classpath). So a Hibernate plugin for Maven should be able to handle
this, but I haven't tried any.

> While this works, I was interested in hearing how
> other folks have dealt with using the hibernate goals
> for a shared set of core objects across multiple
> projects?
> 
> A couple of drawbacks is that since I copy the class
> and hbm files to my new projects, I am getting
> unwanted classes in my new pom jar file (i would
> rather just get the class file from the core project).
> Another drawback (minor) is the time required to
> regenerate the ddl from the mappings when this has
> already been done in the core project.

This doesn't sound like a good solution.. =)

--
Kristian

> 
> Interested in hearing your thoughts.
> Thanks.
> 
> 
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Reuse of hibernate domain objects in multiple maven projects?

Posted by Alex Soto <ap...@gmail.com>.
I'm having a little troubling understanding, but let's assume I do :)

If your hibernate project produces an artifact named domain-1.0.jar that 
contains your hibernate pojo's and mappings. Then you should declare it as a 
dependency in your project.xml for your other projects that depend on it.

You would run "maven jar:install" in your domain project to install it into 
your local repository, or you can publish it to your own remote repository 
so other developers can have access to it.

Alex

On 5/25/05, phillip rhodes <rh...@yahoo.com> wrote:
> 
> 
> I have a core project that encapsulates some domain
> objects that I reuse in many of my projects. Many of
> the domain objects use hibernate to be persisted. I
> use the xdoclet and hibernate plugins to generate the
> mapping files and create the tables in a schema.
> 
> I reuse these core object relational mappings in many
> other projects. Each project has its own schema, so I
> need to create these core tables in each of the other
> schemas.
> 
> So far, I have been copying the class files and
> mapping files to each of these projects using a custom
> maven plugin and running the hibernate:schema-export
> goal for that individual project so that all the
> necessary tables are created. I need to copy the
> class files over or the hibernate plugin will not
> work.
> 
> While this works, I was interested in hearing how
> other folks have dealt with using the hibernate goals
> for a shared set of core objects across multiple
> projects?
> 
> A couple of drawbacks is that since I copy the class
> and hbm files to my new projects, I am getting
> unwanted classes in my new pom jar file (i would
> rather just get the class file from the core project).
> Another drawback (minor) is the time required to
> regenerate the ddl from the mappings when this has
> already been done in the core project.
> 
> 
> Interested in hearing your thoughts.
> Thanks.
> 
> 
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
>