Reuse of hibernate domain objects in multiple maven projects?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Reuse of hibernate domain objects in multiple maven projects?

Phillip Rhodes-2

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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

Kristian Nordal
Hi,

On 5/26/05, phillip rhodes <[hidden email]> 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

Alex Soto
In reply to this post by Phillip Rhodes-2
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 <[hidden email]> 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>