[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: Re[eclipselink-users] fresh entity throws java.lang.IllegalArgumentException
|
If you found the object in the same EntityManager then it should still be
managed, and refresh should work.
Ensure you are not calling clear(), also if in JEE ensure the object was
found in the same transaction, as in a managed EntityManager each
transaction represents a new persistence context.
Otherwise you could be somehow changing the object's primary key, ensure the
primary key is the same. You could try doing a find before the refresh to
see what the registered object is.
SerFingolfin wrote:
>
> Hi everybody.
> My program finds an entity called "module" made as follows :
>
> Module Entity :
>
> @Id
> @GeneratedValue(strategy = GenerationType.IDENTITY)
> @Basic(optional = false)
> @Column(name = "idmodule")
> private Integer idmodule;
> @Column(name = "name")
> private String name;
> @Basic(optional = false)
> @Column(name = "side")
> private String side;
> @OneToMany(mappedBy = "moduleIdmodule", fetch=FetchType.EAGER,
> cascade=CascadeType.ALL)
> private Collection<Cell> cellCollection;
>
> Code :
>
> module = em.find(Module.class, id);
>
> for(...)
> em.insert(new Cell(module,...));
>
> em.refresh(module);
>
> I'm inserting a large amount of Cell entities related to my module istance
> correctly (i see them in the database). After the insert transactions i
> want to refresh my module entity : i need to see the new related
> collection of cells. But when i call "entitymanager.refresh(module)" i
> always get this exception :
> java.lang.IllegalArgumentException: Can not refresh not managed object
> How is it possible? My module entity becomes unmanaged? why? i just found
> it from the database before the inserts ...
>
-----
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/Refresh-entity-throws-java.lang.IllegalArgumentException-tp25167220p25276314.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.