Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Create persistence unit programmically without persistence.xml

James Sutherland wrote:
I suppose that is the main reason you need a persistence.xml, to define the
set of classes/classpath.  I don't think it is possible to deploy JPA
without a persistence.xml.  You could log an enhancement to allow passing
the class list, or orm.xml file with the persistence properties Map, but you
would still need to access the EclipseLink provider directly as JPA
Persistence requires a persistence.xml to know the provider.

Well in the good old days of Hibernate I could just create a session and add my classes to it on the fly. Seems that never made it into SUNs JPA specs. However I have completely removed the provider from the persistence.xml and hand it to EL using the properties of the EMF. This seems to work ok. The only thing left in the persistence.xml is the spec of the classes. I guess it would not be too hard to expose the method that parses the classname in EL and creates the ClassDescriptor for it as a public method of the EL JPA Provider.

Still, JPA inside a dynamic OSGi environment is painful. Hibernate was much more flexible even 4 years ago.

philk wrote:
Hello,

I want to create a persistence unit with out using the persistence.xml. I
am
already feeding EL all the "eclipselink" properties for the database
connection and the class loader. The last thing I struggle to find is, how
to feed EL the entity classes that the PU should be aware of. How would I
do
that?

Thanks,
Phil





Back to the top