Omitted @hibernate.typdef tag in a @hibernate.joined-subclass -------------------------------------------------------------
Key: XDP-133 URL: http://jira.codehaus.org/browse/XDP-133 Project: XDoclet 2 Plugins Type: Bug Components: hibernate Versions: 1.0.2 Environment: Windows XP, ANT 1.6.5, Eclipse 3.1.1 Reporter: Christoph Adl The problem is that if I use the @hibernate.typdef tag in a @hibernate.joined-subclass tag it does not lead to any XML output in the generated mapping file. Example: ==== BaseClass.java ==== package at.arcsmed.kio.beans; /** * @hibernate.class * table = "Base_Class" */ public class BaseClass { /** * @hibernate.id * generator-class = "native" */ private int id; /** * @return Returns the id. */ public int getId() { return id; } /** * @param id The id to set. */ public void setId(int id) { this.id = id; } } ==== DerivedClass.java ==== package at.arcsmed.kio.beans; // i've used the GenericEnumUserType from http://hibernate.org/272.html /** * @hibernate.joined-subclass * table = "DerivedClass" * * @hibernate.typedef * name = "TestEnumType" * class = "at.arcsmed.kio.beans.enums.GenericEnumUserType" * @hibernate.typedef-param * typedef-name = "TestEnumType" * name = "enumClass" * value = "at.arcsmed.kio.beans.DerivedClass$TestEnum" */ public class DerivedClass extends BaseClass { public enum TestEnum { Value1, Value2 } /** * @hibernate.property * type = "TestEnumType" */ private TestEnum test; /** * @return Returns the test. */ public TestEnum getTest() { return test; } /** * @param test The test to set. */ public void setTest(TestEnum test) { this.test = test; } } ==== BaseClass.hbm.xml (generated via xdoclet2 1.0.2) ==== <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class table="Base_Class" name="at.arcsmed.kio.beans.BaseClass"> <id name="id"> <generator class="native"/> </id> <joined-subclass name="at.arcsmed.kio.beans.DerivedClass" table="DerivedClass"> <key/> <property name="test" type="TestEnumType"/> </joined-subclass> </class> </hibernate-mapping> ============= There is no sign of my typedef :-(. While creating the example i realised, that there is a problem with the ANT integration as well. If i make changes to the DerivedClass.java-File, the BaseClass.hbm.xml file is not re-generated! This problem is probably a result of the fact, that the DerivedClass-Mapping must be included in the mapping file of BaseClass (a speciality of the Hibernate DTD). The solution is, to create the typedef-element in BaseClass.hbm.xml outside the class element (this must happen for the whole inheritance tree - so for joined-subclass elements in joined-subclass elements as well). So here is the proper BaseClass.hbm.xml file: <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <typedef class="at.arcsmed.kio.beans.enums.GenericEnumUserType" name="TestEnumType"> <param name="enumClass">at.arcsmed.kio.beans.DerivedClass$TestEnum</param> </typedef> <class table="Base_Class" name="at.arcsmed.kio.beans.BaseClass"> <id name="id"> <generator class="native"/> </id> <joined-subclass name="at.arcsmed.kio.beans.DerivedClass" table="DerivedClass"> <key/> <property name="test" type="TestEnumType"/> </joined-subclass> </class> </hibernate-mapping> As a result of the missing typedef I get an error during the creation of the database schema with hibernate: Exception in thread "main" org.hibernate.MappingException: Could not determine type for: TestEnumType, for columns: [org.hibernate.mapping.Column(test)] [java] at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:265) [java] at org.hibernate.mapping.Column.getSqlTypeCode(Column.java:128) [java] at org.hibernate.mapping.Column.getSqlType(Column.java:172) [java] at org.hibernate.mapping.Table.sqlCreateString(Table.java:263) [java] at org.hibernate.cfg.Configuration.generateSchemaCreationScript(Configuration.java:669) [java] at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:65) [java] at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:49) [java] at at.arcsmed.kio.test.HibernateSchema.createSchema(HibernateSchema.java:29) [java] at at.arcsmed.kio.test.HibernateSchema.main(HibernateSchema.java:24) -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira ------------------------------------------------------- SF.Net email is sponsored by: Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php _______________________________________________ xdoclet-plugins-interest mailing list xdoclet-plugins-interest@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xdoclet-plugins-interest