Java – is there any way to provide persistenceunitname for spring’s localcontainerentitymanagerfactorybean instead of using persistence xml?

I have multiple data sources and multiple entitymanagerfactories defined in my spring context

If there is only entitymanagerfactory, we do not need to provide persistenceunitname However, to associate entitymanager with @ persistencecontext to correct entitymanagerfactory, I should give unitname = "somepu" attribute

However, if we name the persistenceunitname attribute, spring expects that the These persistenceunitname declarations are used in the XML file

Is there any way to provide persistenceunitname for spring's localcontainerentitymanagerfactorybean instead of using persistence xml?

When I use persistence. In spring's localcontainerentitymanagerfactorybean XML, I found another problem The packagestoscan property does not work I need to list persistence All entity classes in XML

Do you know why?

-siva

Solution

Specifying properties in the localcontainerentitymanagerfactorybean suits me

<property name="persistenceUnitName" value="MyPersistenceUnit"/>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>