-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Version column and Joined Inheritance
PostPosted: Mon Sep 29, 2008 7:27 am 
Newbie

Joined: Mon Oct 04, 2004 7:13 am
Posts: 19
The EntityManager.lock() seems to use the wrong column name when it is passed a sub-type entity froma joined inheritance strategy.

ie, I would expect to see:
update SUPER set ROW_VERSION_SEQ=? where SUPER_ID=? and ROW_VERSION_SEQ=?

but instead I see:

update SUPER set ROW_VERSION_SEQ=? where SUB_ID=? and ROW_VERSION_SEQ=?


which throws a org.hibernate.exception.SQLGrammarException: could not retrieve version:
because column SUB_ID does not exist on table SUPER.






Hibernate core 3.3.1, Anotations 3.3.1, EntityMnager 3.4


@Entity(name = "Company")
@Table(name="COMPANY")
@PrimaryKeyJoinColumn(name = "COMPANY_ID")

public class Company extends Party {
...


@Entity(name = "Party")
@Table(name = "PARTY")
@Inheritance(strategy = InheritanceType.JOINED)
public class Party extends AbstractVersionedEntity implements EntityWithUUID {


private String key;
@Id
@GeneratedValue(generator="system-uuid")
@GenericGenerator(name="system-uuid", strategy="uuid")
@Column(name="PARTY_ID")
public String getKey() {
return key;
}

public void setKey(String key) {
this.key = key;
}



@MappedSuperclass
public abstract class AbstractVersionedEntity extends AbstractEntity implements VersionedEntity {

/** The version. */
private Integer version;

@Version
@Column(name = "ROW_VERSION_SEQ")
public Integer getVersion() {
return version;
}
...





Code:

Company company= entityManager.find(Company.class, "12345");

entityManager.lock(company, LockModeType.WRITE);







The generated SQL:

Hibernate: update PARTY set ROW_VERSION_SEQ=? where COMPANY_ID=? and ROW_VERSION_SEQ=?



Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.