From: Christopher G. S. II (JIRA) <no...@at...> - 2006-07-20 19:26:13
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1848?page=comments#action_23708 ] Christopher G. Stach II commented on HHH-1848: ---------------------------------------------- At SelectLockingStrategy:108, the root table name is being requested; however, JoinedSubclassEntityPersister doesn't override AbstractEntityPersister's getRootTableName. AEP's getRootTableName returns the subclass' table name. > A session.lock generates a query with a version column in a joined subclass which does not exist > ------------------------------------------------------------------------------------------------ > > Key: HHH-1848 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1848 > Project: Hibernate3 > Type: Bug > Versions: 3.2.0.cr2 > Environment: Windows XP Pro SP2 (full update) > Java 1.5.0_06 > Postgres 8.1 > postgresql-8.1-404.jdbc3.jar > Annotations 3.2.0 cr1 > hibernatetools-3.1.0.beta5 > Reporter: Eduard Mossinkoff > Priority: Minor > Attachments: screenshot-1.jpg, screenshot-1.jpg > > > A joined class hierarchy using annotations has a version property named "optlock" like in the annotation reference. > The session factory in the Eclipse Hibernate console shows the joined subclass and it contains the "id" and "version" properties inherited from its superclass. The generated schema only has the version property in the table representing the root entity. The subclass has no "optlock" column. Now when a session.lock() is called with an instance of the subclass as its parameter and lockmode "UPGRADE", a query is generated including the "optlock" column on the subclass table which doesn't exist in the schema. > The root entity, only showing the relevant properties > @Entity > @Inheritance(strategy = InheritanceType.JOINED) > @AccessType("field") > public class ModelObject implements Serializable, AccessControl { > private static final long serialVersionUID = 2354579396538279696L; > transient public static final int STORAGE_COSTS = 10; > @Id > @GeneratedValue(generator = "system-uuid") > @GenericGenerator(name = "system-uuid", strategy = "uuid") > private String id; > @Version > @Column(name="optlock") > private Integer version; > } > A sub class > @Entity > @AccessType("field") > public class Item extends ModelObject implements Cloneable, Serializable { > } > @Entity > @AccessType("field") > public class Domain extends Item { > protected String domainId = null; > } > @Entity > @AccessType("field") > public class UserDomain extends Domain { > private long lastLoginDate; > } > The Hibernate console shows: > org.across.model.UserDomain > +id:java.lang.String > +version:java.lang.Integer > The database table of ModelObject > CREATE TABLE dev.modelobject > ( > id varchar(255) NOT NULL, > optlock int4, > acl_id varchar(255), > CONSTRAINT modelobject_pkey PRIMARY KEY (id), > CONSTRAINT fk78ba6fa841f3e430 FOREIGN KEY (acl_id) > REFERENCES dev.acl (id) MATCH SIMPLE > ON UPDATE NO ACTION ON DELETE NO ACTION > ) > WITHOUT OIDS; > ALTER TABLE dev.modelobject OWNER TO across; > The UserDomain table > CREATE TABLE dev.userdomain > ( > id varchar(255) NOT NULL, > lastlogindate int8 NOT NULL, > CONSTRAINT userdomain_pkey PRIMARY KEY (id), > CONSTRAINT fkbbd6448faf7c2769 FOREIGN KEY (id) > REFERENCES dev."domain" (id) MATCH SIMPLE > ON UPDATE NO ACTION ON DELETE NO ACTION > ) > WITHOUT OIDS; > ALTER TABLE dev.userdomain OWNER TO across; > The query generated when calling session.lock(userDomain, LockMode.UPGRADE); where userDomain is an instance created in a different session that was closed. > Hibernate: select id from dev.UserDomain where id =? and optlock =? for update > 7625 [main] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: 42703 > 7625 [main] ERROR org.hibernate.util.JDBCExceptionReporter - ERROR: column "optlock" does not exist > The "optlock" column is not present in the UserDomain table only in the ModelObject table. > The question is, is the generated query wrong or is the Hibernate Eclipse tool generating a wrong schema. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |