Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Question on Eclipselink Internals

Hi, Thilo

What about transactions? Are you managing them manually? I mean is the transaction with a and b updates already committed when you are trying to access data from another session?

Thanks.
—
Best regards.
Iaroslav


On 5 Mar 2014, at 12:34, Thilo Tanner <thilo.tanner@xxxxxxxxx> wrote:

> Hi all,
> 
> I mainly used Hibernate and Ebean in the last years. For a new project
> I switched to Eclipselink and so far I'm very happy with the results.
> The framework is much easier to use, especially if you want to map an
> existing DB. Great job!
> 
> One thing puzzles me concerning 1:N relationships. I have two very
> simple classes:
> 
> class A {
>  @OneToMany(mappedBy = "a")
>  private List<B> bs;
>  ...
> }
> 
> class B {
>  @ManyToOne
>  private A a;
>  ...
> }
> 
> It seems, that Eclipselink is caching the original object persisted
> during runtime. So if I create objects
> 
> A a = new A();
> em.persists(a);
> 
> B b = new B();
> b.setA(a);
> em.persists(b);
> 
> When I access a from another session, I expected that a.getBs() is
> filled with the b object created above, which isn't the case.
> a.getBs() is empty, unless I create the back-link by hand during
> creation:
> 
> a.getBs().add(b)
> 
> This is the correct and intended behavior for objects created during
> runtime, correct? As long as the object isn't updated, I always get
> the original object, I once created, from the session, right? Not that
> this is an issue, it is just something worth to know when working with
> the framework.
> 
> Thanks for all your inputs!
> 
> Best,
> Thilo
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users



Back to the top