java


LocalContainerEntityManagerFactoryBean cannot be converted to EntityManagerFactory


I don't understand, what is happening at all!
Suddenly, simple things stopped to work!
Now ehen I am trying to define something like here http://docs.spring.io/spring-data/jpa/docs/1.10.6.RELEASE/reference/html/#jpa.java-config
I get the following compile error
incompatible types: org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean cannot be converted to javax.persistence.EntityManagerFactory
And this is correct, since LocalContainerEntityManagerFactoryBean does not implement EntityManagerFactory, which is required by JpaTransactionManager#setEntityManagerFactory() method.
How it cn be, that official example contains absolutely incorrect snippet? How it can be, that this snippet was compiling for me for some time?
What I broke?
UPDATE
I was able to rewrite
txManager.setEntityManagerFactory(entityManagerFactory());
to
txManager.setEntityManagerFactory(entityManagerFactory().getObject());
So it is an error in the doc?
txManager.setEntityManagerFactory(entityManagerFactory());
is not suppose to work you either have to do this
txManager.setEntityManagerFactory(entityManagerFactory().getObject());
or
txManager.setEntityManagerFactory(entityManagerFactory().getNativeEntityManagerFactory()
so honestly I don't know why it previously worked.
I guess it is a mistake since I tried that way as described in the official doc and It didn't work
Yes the doc is wrong
use this code to inject entity manager factory into txManager
#Bean #Autowired public PlatformTransactionManager transactionManager(EntityManagerFactory factory) {
JpaTransactionManager txManager = new JpaTransactionManager();
txManager.setEntityManagerFactory(factory);
return txManager;
}

Related Links

Why is my android view's width 0?
How do I show a notification in IntelliJ?
wiringPiISR core dump in Java
java.lang.NoClassDefFoundError when upload POJOs models in Guvnor
Head First Java program explanation
Java HttpURLConnection failed to connect to ASP.NET API, connection refused
Inject JMockit mocks into Spring context
Enable Hibernate filter when search by primary/foreign keys
java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/persistence/EntityExistsException
Return .p12 file to client without creating keystore file
How to handle negative int with Java ByteBuffer
JavaFX set mouse hidden when idle
Swift equivalent of inputStream
How to pass information with a get properly in java
Eclipse reading StdIn(System.in) from console, but will not give any output
Does Google App Engine supports Websphere MQ

Categories

HOME
log4j
atom-editor
oracle11g
dot
grep
sqlite-net-extensions
graphql
win32gui
alpha
wamp
swagger-ui
cross-validation
medical
kibana-4
facebook-php-sdk
google-cloud-spanner
karma-jasmine
scichart
emulator
zapier
devops
smb
linkerd
spring-mybatis
assistant
libssl
gsmcomm
gsoap
google-rich-snippets
create-table
copying
framemaker
accelerate-framework
force-layout
host
wixsharp
revolution-slider
git-merge
adobe-premiere
scaffold
webix-treetable
uft-api
greenrobot-eventbus
squib
dynamic-reports
reportingservices-2005
unixodbc
cubic-spline
fault
zip4j
python-c-api
worksheet
python-webbrowser
yii2-extension
recursive-datastructures
darcs
worker-thread
epson
log4c
google-web-starter-kit
hill-climbing
pickadate
srand
maven-tomcat-plugin
icu4j
embedded-code
drawbitmap
graph-drawing
mono-embedding
sortedlist
device-orientation
titanium-modules
dealloc
bundles
html5-notifications
floating-point-precision
quantlib-swig
aqtime
bulkloader
buster.js
eventlistener
type-equivalence
browser-detection
appconkit
eclipse-templates
external-accessory
remember-me
blitz++
zend-translate
forums
compiler-specific
photoshop-cs4
nerddinner
ntvdm.exe

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App