[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Problem after trying to insert a new object
|
Hi James,
Thanks for the answer. I think i already tried to solve the problem by calling EntityManager#clear() without success.
I will try to get a new instance of EntityManager tomorrow, if it works i will tell you.
On Mon, Feb 9, 2009 at 4:53 PM, James Sutherland
<jamesssss@xxxxxxxxx> wrote:
If an error occurs, you cannot continue to use the same EntityManager. You
should either get a new EntityManager, or call clear(). All objects managed
by the EntityManager will become detached, you should not continue to use
these objects.
JPA does not provide for error handling. EclipseLink's native UnitOfWork
API does have some support for error handling using its
commitAndResumeOnFailure, revert, API's, but these are not currently exposed
through JPA.
bests
Rodrigue Lagoue Njinthe wrote:
>
> Hi all!
> i have a curious problem using eclipselink
>
> i have the following classes
>
> public class HealthProfessional {
> private Institution institution;
> }
>
> public class Network {
> private List<Institution> institutions;
> }
>
> public class Institution {
> private List< HealthProfessional > healthprofessionals;
> }
>
> NB: i remove the jpa annotations, but i can assure that they are correct.
>
> The problem:
>
> I use stored procedures (i configured it by implementing the
> DescriptorCustomizer interface) to write changes and new object to an
> oracle
> Database (10g), and read information from views.
>
> But by adding a new HealthProfessional there is an exception thrown from
> the
> database (the issue is being resolved by somebody else). Since i use a
> strongly tied domain model, i build all the relations between the
> instances
> involved before saving. I catch the exception coming from the database and
> suppose the system would continue to work without problem.
> - But the next time i tryied to refresh the corresponding network, i get
> an
> Exception from the EntityManager telling that the Network instance is no
> more managed.
> - so i fixed by catching the exception and retrieve a new instance
> using
> EntityManager#find() method
>
> - by the next commit (another use cases) i find out that the old network
> instance is always somewher in the session, because eclipselink tries to
> insert it (as new object), although the id is already setted on it.
>
> A possible solution could be to set eclipselink so that, it insert objects
> only if it was explicitely required (calling EntityManager#persist() or
> EntityManager#merge() methods). Is there a way to do it?
>
> if not, how can i solve the problem
>
> thanks for any help
>
> Rodrigu
>
>
-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland
http://www.eclipse.org/eclipselink/
EclipseLink , http://www.oracle.com/technology/products/ias/toplink/
TopLink
Wiki: http://wiki.eclipse.org/EclipseLink EclipseLink ,
http://wiki.oracle.com/page/TopLink TopLink
Forums: http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
http://www.nabble.com/EclipseLink-f26430.html EclipseLink
Book: http://en.wikibooks.org/wiki/Java_Persistence Java Persistence
--
View this message in context: http://www.nabble.com/Problem-after-trying-to-insert-a-new-object-tp21876093p21915620.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users