Comments (8)
did you tried
cloner.nullInsteadOfClone(SessionImplementor.class, JDBCTransaction.class,
SessionImpl.class); (and the rest of hibernate's classes)?
or maybe
cloner.dontClone(SessionImplementor.class, JDBCTransaction.class,
SessionImpl.class);
Hibernate returns proxies and cloning those is troublesome. Also cloning
entities might confuse hibernate, so avoid using cloning entities when updating
the database.
Original comment by [email protected]
on 16 Apr 2013 at 7:50
from cloning.
... but cloning entities is exactly what I want :-) Will give your statements a
try...
Original comment by [email protected]
on 17 Apr 2013 at 10:00
from cloning.
Solved the error by removing the @Audited (hibernate.envers) tags.
Unfortunately the foreign keys in the lineSectionSchedules table still point to
the old/original entities. Tried cloner.dontClone(SessionImplementor.class,
JDBCTransaction.class, SessionImpl.class); but makes no difference. Maybe the
original foreign keys are also cloned?
Original comment by [email protected]
on 18 Apr 2013 at 5:22
from cloning.
I don't know the internals of hibernate, and it gets tricky. Hibernate uses a
lot of proxies and also newer version might behave differently.
Cloner deep clones instances and for its purposes it doesn't know if an
instance is a hibernate entity. Maybe you will be able to achieve what you need
but making sure hibernate entities are cloned and the clones are "ok" with
hibernate is out of the scope of this library.
The way I use cloner when working with hibernate is to never use cloned
instances in calls to hibernate as a lot of weird things can happen. And I use
cloner.extraNullInsteadOfClone for the following:
org.hibernate.engine.spi.SessionImplementor
org.hibernate.internal.SessionImpl
org.hibernate.internal.StatelessSessionImpl
org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction
So I am afraid I can't help, maybe ask on a hibernate forum and see if someone
can tell you which internal hibernate classes shouldn't be cloned. Or maybe
debug your code and whenever you see a hibernate class proxied within your
entity, do a
cloner.dontClone(Class)
Original comment by [email protected]
on 18 Apr 2013 at 5:47
- Changed state: WontFix
from cloning.
It seemed to work one day when I take a look at
http://alexander.holbreich.org/2012/02/release-your-entities Maybe it was
Hibernate 3 (I use HIbernate 4). Will ask at the Hibernate forum, maybe they
have some suggestions.
Original comment by [email protected]
on 19 Apr 2013 at 7:00
from cloning.
Alexander Holbreich confirmed it was Hibernate 3...
Original comment by [email protected]
on 19 Apr 2013 at 12:57
from cloning.
Hi Michael, do you mean you got working code? Can you share an example?
Original comment by [email protected]
on 19 Apr 2013 at 10:02
from cloning.
No, switched to this project: https://github.com/nociar/jpa-cloner. It does a
deep cloning on my Hibernate entities.
Original comment by [email protected]
on 23 Apr 2013 at 9:20
from cloning.
Related Issues (20)
- NoClassDefFoundError HOT 1
- Invalid clone result for List.of() and Set.of() objects on JDK15 HOT 2
- illegal reflective access HOT 1
- Java 16 Support HOT 16
- download url in wiki/downloads.md is 404 HOT 1
- About instantiation. HOT 3
- Avoid throwing and catching ClassNotFoundException for SubList and RandomAccessSubList
- Bump objenesis to 3.2
- Illegal reflective access by com.rits.cloning.Cloner$CloneObjectCloner for Timestamp.nanos HOT 1
- why use "I" of interface prefix HOT 3
- Java module
- Version 1.11 not available at Maven Repository? HOT 3
- java.util.Date cloning error HOT 2
- java.lang.IllegalArgumentException: Can not set final java.lang.String field org.apache.logging.log4j.Level.name to org.apache.logging.log4j.Level
- java.lang.NoClassDefFoundError:
- Objenesis dependency version maintenance in this repo HOT 1
- Stackoverflow when deepclone an object with recursive references.
- Java 17 support for complex deep cloning HOT 2
- Custom cloning HOT 3
- Latest Release Update? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cloning.