Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] New instances and resolving mappings

Hello,

Yes, only entities obtained from an EntityManager will be populated by the persistence provider. If you instantiate a new entity instance, it has no connection to the EntityManager to get data.
Best Regards,
Chris

Clogs wrote:
Hello all,
I am faced with a problem which I am unable to get a grip on. This is the
scenario:
I instantiate a POJO which is annotated as an Entity. In the POJO there are
annotations which are used to reference other tables in the database, like: @ManyToOne(fetch=FetchType.LAZY,optional=false) @JoinColumn(name="LEVNR", referencedColumnName = "LEVNR", insertable = false, updatable = false) private Leverancier leverancier; public Leverancier getLeverancier() { return leverancier; } public void setLeverancier(Leverancier leverancier) { this.leverancier = leverancier; }
When I now invoke getLeverancier() on the instantiated object, I would
expect a trip to the database to get the information. However, this never
happens, 'leverancier' remains null and the application falls over. The
information to retrieve the required leverancier is set-up correctly
(LEVNR). Does the newly created entity need be managed in order for mappings to work? Am I overlooking anything?
Thanks...all help is appreciated



Back to the top