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

Returning value to main method in java
Formatting datetime using joda-time and parseDateTime ignoring fraction of second
Android - changing Button text and TextView visibility with custom onKeyPreIme (backpress)
Chained Array Value
Linked list output NameOfTheList#something [duplicate]
How to search for a substring from an user input string and print out
Removing trailing and leading spaces
Why hash set allows adding duplicate object?
Using KeyFieldBasedPartitioner and Secondary Sorting in Java Hadoop similar to Hadoop Streaming
Jtextfield search in database msql using keylistener
java opening zip files into memory
getStringArrayExtra() always return null
Converting unicode symbols to their code
Java blueJ class Member / Lan
Android - How to pick numbers from a generated list?
L-System with Java

Categories

HOME
ms-access
testing
mockito
single-sign-on
google-play
json.net
onedrive
syntax
bpmn
webstorm
read-eval-print-loop
spring-cloud-stream
spring-jdbc
tizen-web-app
sql-server-2016
flyway4
synchronization
dacpac
kentor-authservices
izpack
uitypeeditor
finite-automata
apache-metamodel
undefined
flux
samoa
alpine
clickonce
restful-authentication
android-widget
p-value
kannel
fopen
azure-sql-database
atl
nssegmentedcontrol
jmonkeyengine
host
wixsharp
adobe-premiere
scaffold
x11-forwarding
bootstrapper
user-controls
mesos-chronos
ensembles
node-gyp
bootstrap-dialog
flickr-api
atomicity
togetherjs
elgg
colorama
forever
csound
magma
gcsfuse
angular-strap
setuptools
angular-cache
httplistener
ado.net-entity-data-model
measures
plottable.js
prettytensor
actionbardrawertoggle
pickadate
hexdump
php-parse-error
spim
tmuxinator
content-length
pundit
wyam
deis
sailfish-os
sniffer
c3
camanjs
relocation
socketexception
google-reader
htmlcleaner
algebraic-data-types
c18
cdc
inbox
clipper
simba
hamiltonian-cycle
sublist
bluepill
dsn
multipage
objective-c-2.0
osql
gcj
file-comparison
winbugs14
mysql-error-1005
putchar

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App