Caused by: java.lang.IllegalArgumentException: Cannot fetch unpersisted entity

144 views
Skip to first unread message

tzhotmail

unread,
Dec 19, 2011, 4:59:16 PM12/19/11
to Google Web Toolkit
Hi,

I have a base Entity class with subclasses as shown below. I can
view and update my entities but I get the exception
java.lang.IllegalArgumentException: Cannot fetch unpersisted entity
whenever I try to save /persist a new entity.

Does request factory support inheritance ?


@MappedSuperclass
public class Base implements java.io.Serializable{
/**
*
*/
private static final long serialVersionUID = -3767474991121795712L;
private Integer version = 0;
protected Long id;
/**
* Auto-increment version # whenever persisted
*/
@PrePersist
void onPersist()
{
this.version++;
}


@Transient
public Integer getVersion()
{
return version;
}

public void setVersion(Integer version)
{
this.version = version;
}

@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name = "id", unique = true, nullable = false)
public Long getId() {
return this.id;
}

public void setId(long id) {
this.id = id;
}

}

And Other classes as follows

@Entity
@Table(name = "Action")
public class Action extends Base {

/**
*
*/
private static final long serialVersionUID = -1034167141757868139L;

private String name;
private String creationUser;
private Date creationDate;
private String modUser;
private Date modDate;
private Set<Rule> ruleses = new HashSet<Rule>(0);

public Action() {
}

public Action(long id, String name, String creationUser, Date
creationDate,
String modUser, Date modDate) {
this.id = id;
this.name = name;
this.creationUser = creationUser;
this.creationDate = creationDate;
this.modUser = modUser;
this.modDate = modDate;
}

public Action(long id, String name, String creationUser, Date
creationDate,
String modUser, Date modDate, Set<Rule> ruleses) {
this.id = id;
this.name = name;
this.creationUser = creationUser;
this.creationDate = creationDate;
this.modUser = modUser;
this.modDate = modDate;
this.ruleses = ruleses;
}

@Column(name = "name", nullable = false, length = 2000)
public String getName() {
return this.name;
}

public void setName(String name) {
this.name = name;
}

@Column(name = "creationUser", nullable = false, length = 10)
public String getCreationUser() {
return this.creationUser;
}

public void setCreationUser(String creationUser) {
this.creationUser = creationUser;
}

@Temporal(TemporalType.TIMESTAMP)
@Column(name = "creationDate", nullable = false, length = 23)
public Date getCreationDate() {
return this.creationDate;
}

public void setCreationDate(Date creationDate) {
this.creationDate = creationDate;
}

@Column(name = "modUser", nullable = false, length = 10)
public String getModUser() {
return this.modUser;
}

public void setModUser(String modUser) {
this.modUser = modUser;

Thomas Broyer

unread,
Dec 20, 2011, 9:48:29 AM12/20/11
to google-we...@googlegroups.com


On Monday, December 19, 2011 10:59:16 PM UTC+1, tzhotmail wrote:
Hi,

I have a base Entity class  with subclasses as shown below.  I can
view and update my entities but I get the exception
java.lang.IllegalArgumentException: Cannot fetch unpersisted entity
whenever I try to save /persist a new entity.

What does throw this exception? (I suppose Hibernate, Datanucleus or whichever JPA implementation you're using)
And when? (which method, and what's the stack-trace?)
 

Does request factory support inheritance ?


Yes.

tzhotmail

unread,
Dec 23, 2011, 6:49:01 AM12/23/11
to Google Web Toolkit
Hi ,

The AbstractRequestFactory in the client throws this exception, method

public <P extends EntityProxy> Request<P> find(EntityProxyId<P>
proxyId) {
if (((SimpleEntityProxyId<P>) proxyId).isEphemeral()) {
throw new IllegalArgumentException("Cannot fetch unpersisted
entity");
}

but the weird issue is that the data is persisted to the database.
RuleProxy is a new entity with no persistent id, but
ActionProxy,ResourceProxy and Subject all have a persistent id.

The entities/proxy are as follows
public interface RuleProxy extends EntityProxy {
.......

abstract ResourceProxy getResource();

abstract void setResource(ResourceProxy resource);

abstract ActionProxy getAction();

abstract void setAction(ActionProxy action);

abstract Set<com.citi.gpf.cues.client.proxy.SubjectProxy>
getSubjects();



the call to persist:
request.persist(RuleProxy).fire() ; I am doing something wrong
here ???

then I call a finder method as follows
requests.find(proxyId).with("resource", "action",
"subjects").fire(callback);
I am just wondering whether I am calling the finder method before the
persist request has been returned.


thanks,

-sowdri-

unread,
Dec 26, 2011, 1:39:38 AM12/26/11
to google-we...@googlegroups.com
Can you post the class firing the below request?
Reply all
Reply to author
Forward
0 new messages