开发者

How to get rid of "The persisted entity with id XXX has a null version" in GWT?

开发者 https://www.devze.com 2023-03-11 23:19 出处:网络
I am currently developing an app with GWT/RequestFactory and Hibernate/JPA as a peristence provider. So I have started to modify my Entity classes, created EntityProxies, put the V开发者_如何学编程er

I am currently developing an app with GWT/RequestFactory and Hibernate/JPA as a peristence provider.

So I have started to modify my Entity classes, created EntityProxies, put the V开发者_如何学编程ersion column with the corresponding mapping in orm.xml (sorry for annotations aficionados, I'm still doing it the old way), got hibernate generate database schema correctly but when I try to do things in it i have the exception :

@ProxyFor(XXXXX)
public interface UserProxy extends EntityProxy {
    public Long getId();
    public void setId(Long id);
    public Integer getVersion();
    public void setVersion(Integer version);

    // removed ...
}

"The persisted entity with id XXX has a null version"

I have a look at the Database table, the version column is there ... with a value

so can somebody tell me what's wrong ? Any help would be appreciated ...

thanks a lot,


Set a breakpoint in SimpleRequestProcessor.createReturnOperations() where the domainVersion != null check is being made. Is the object that has no version newly-created by the service methods, or is it one that has been operated on by the client? If it's newly-created, do you have some kind of request-scoped auto-commit going on where the version would be assigned after the request has finished? If it's an entity that has been mutated by the client, see if removing the setId() and setVersion() methods helps. In general, your EntityProxy interface should not include the setId() and setVersion() methods, since those properties should only ever be set by your persistence mechanism.


If you're using a Locator class, another cause can be the Locator getVersion() method returning null instead of e.g. returning the entity's version. Eclipse generates a null return value by default.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号