[ http://jira.codehaus.org/browse/XDP-133?page=all ]
Konstantin Pribluda closed XDP-133.
-----------------------------------
Assignee: Konstantin Pribluda
Resolution: Fixed
Fix Version/s: 1.0.4
Typedef problem is fixed, regenration improvement is moved to XDP-199
> Omitted @hibernate.typdef tag in a @hibernate.joined-subclass
> -------------------------------------------------------------
>
> Key: XDP-133
> URL: http://jira.codehaus.org/browse/XDP-133
> Project: XDoclet 2 Plugins
> Issue Type: Improvement
> Components: hibernate
> Affects Versions: 1.0.2
> Environment: Windows XP, ANT 1.6.5, Eclipse 3.1.1
> Reporter: Christoph Adl
> Assigned To: Konstantin Pribluda
> Priority: Minor
> Fix For: 1.0.4
>
>
> 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
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
xdoclet-plugins-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xdoclet-plugins-interest