Hi, If the properties you are trying to set are configurable when the EntityManager is created then you could pass them using EMF#createEntityManager(Map props). There's also xml syntax for injecting these with blueprint:
<bean id="contextWithProps"> <jpa:context property="em"> <map> <entry key="one" value="eins" /> <entry key="two" value="zwo" /> </map> </jpa:context> </bean> If the properties you want to set can only be set at EntityManagerFactory creation time then using your own ManagePersistenceUnitInfoFactory is a pretty good idea (although it is a reasonably large amount of effort). Subclassing/wrapping the existing implementation obviously risks you being broken unexpectedly (it's not part of the API). Regards, Tim > Date: Mon, 20 Jun 2011 16:31:02 +0200 > Subject: Re: Attaching jpa persistence.xml via fragments to a persistence > bundle > From: marcel.hanser.w...@googlemail.com > To: user@aries.apache.org > > Thank for you answers, > > so a usage of fragments failes.... I realy reluctant would create n > (dbms) * m (jpa provider) * k (log level) * etc.... times bundles, > with the same classes and just deversity persistence.xml. Do you have > a best practice for me how to reference a persistence.xml (or just the > provider specific properties) which is not part of my persistence > bundle? > Maybe using a selfwritten > org.apache.aries.jpa.container.ManagedPersistenceUnitInfoFactory which > has preconfigured properties/settings for a specific persistence unit > and merges them? > > Regards, > Marcel > > 2011/6/20 Timothy Ward <timothyjw...@apache.org>: > > Hi, > > > > There is another much more important reason to use getEntry, the JPA > > container processes persistence bundles as they are installed to prevent any > > classes being able to be loaded before the metadata can be parsed. We then > > immediately create an EntityManagerFactory as the bundle resolves. If any > > classes were to be loaded before we created the EntityManagerFactory then it > > would not be possible to load-time enhance the entity classes. > > > > Unfortunately there are no fragments attached when the bundle is in the > > INSTALLED state. Using getResource() would cause the bundle to move to > > RESOLVED which we don't want either. > > > > Regards, > > > > Tim > > > >> Subject: Re: Attaching jpa persistence.xml via fragments to a persistence > >> bundle > >> From: n...@apache.org > >> Date: Mon, 20 Jun 2011 09:05:29 +0100 > >> To: user@aries.apache.org > >> > >> Hi, > >> > >> getResource does something very different from getEntry. getResource uses > >> the Bundle-Classpath so it doesn't guarantee to return > >> META-INF/persistence.xml rooted in the bundle. That is why getResource is > >> not used. > >> > >> I don't know why fragments aren't processed, other people in the list can, > >> I'm sure, explain why. > >> > >> Alasdair Nottingham > >> > >> On 20 Jun 2011, at 07:56, Marcel Hanser > >> <marcel.hanser.w...@googlemail.com> wrote: > >> > >> > Hi, > >> > > >> > i would like to attach a persistence.xml, or more percise parts of it, > >> > to my jpa persistence bundle, since the concrete provider and DBMS > >> > configuration should be chooseable without modify the persistence > >> > bundle. > >> > I scanned a the aries jpa code and found the > >> > org.apache.aries.jpa.container.ManagedPersistenceUnitInfoFactory > >> > plug-in point and also the > >> > > >> > org.apache.aries.jpa.container.impl.PersistenceBundleHelper.locateFile(Bundle, > >> > String) method. And now im wondering why using bundle.getEntry(String) > >> > instead of bundle.getResource(String). Since fragments are not scanned > >> > when using bundle.getEntry(String). > >> > So is there already a way for doing that and i just missed it? > >> > > >> > Thanks in advance. > >> > > >> > Marcel Hanser > >