-->
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.  [ 2 posts ] 
Author Message
 Post subject: Using SchemaExport to generate DDL from EJB3 Application
PostPosted: Thu Jun 01, 2006 6:22 pm 
Newbie

Joined: Thu Jun 01, 2006 11:31 am
Posts: 9
Hibernate version: 3.2.CR2
Hibernate annotations: 3.2.0.CR1
Hibernate EntityManager 3.2.0.CR1

Is there a way to create DDL using SchemaExport and still be able to use a 'vanilla' EntityManagerFactory?

Let me explain the question:

I need to be able to generate DDL for my persistent classes using EJB3. I understand that the EJB3 specification pretty much ignores this need
and that I have to delve into implementation-specific services, however I'm having an issue with how I had to go about this.

I've discovered that, if I want to use Hibernate's SchemaExport class to do this generation, I have to create the EntityManagerFactory using
the EJB3Configuration class rather than javax.persistence.Persistence. e.g.

EJB3Configuration ejb3Config = new Ejb3Configuration(); // get EJB3 config
EntityManagerFactory emf = ejb3Config.createEntityManagerFactory(PERSISTENCE_UNIT, configOverrides); // create EMF for use with DDL work.


This means I have two choices:

1. Create two EntityManagerFactories - one created using javax.persistence.Persistence.createEntityManagerFactory(),
the other created using the EJB3Configuration class.
2. Create one EntityManagerFactory using the Ejb3Configuration.

The first option is why carry two? - I'm now having to carry two EMFs: one for DDL generation and one for DML work - that seems a bit wasteful.

The second option has a problem in that I'm having to pull in implementation-specific code to support my DML work - I'd expect that of the DDL
work - since the specification ignores that but not the DML work.

I was striving to keep the DML side of the house as generic as possible, but, with the requirement of creating DDL, I've had to compromise the
design and de-partition some of the logic.

I also tried creating an EJB3Configuration on the fly and using a javax.persistence.Persistence created EntityManagerFactory, but, alas, this
did not work - for SchemaExport to work - an EntityManagerFactory has to be created from the EJB3configuration before that configuration can
be used to create the DDL.

So - my question then - is there some what to provide DDL creation capabilities using the hibernate implementation of EJB3 and still use an
EntityManagerFactory created using javax.persistence.Persistence.createEntityManagerFactory();

I apologise for the long ramble - but it strikes me that surely the javax.persistence.Persistence.createEntityManagerFactory() call could be
doing the work that the EJB3Configuration.createEntityManagerFactory() is doing 'under the covers' so to speak and a propritary interface could
be offered that could obtain the ejb3COnfiguration from a given EntityManagerFactory.

Opinions on this please?

-Thom


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 26, 2006 6:31 am 
Newbie

Joined: Wed Jan 05, 2005 2:28 pm
Posts: 14
Location: Germany, Munich
I have exactly the same problem. Have you found a solution?


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