利用hibernatedoclet生成hbm文件遇到的问题20
现在项目中用ant hibernatedoclet自动生成pojo的hbm文件,生成简单的pojo很正常。如果一个类的继承有两层以上的话,只能生成父类的字段,祖父及以上类的字段无论如何都生成不了。
如ExamQuestion继承了Question,Question是一个抽象类,继承自BusBaseObject,在用ant hibernatedoclet生成hbm文件时,只能生产Question类中的字段配置,没有生成BusBaseObject中的字段配置。但是对于其它直接继承BusBaseObject的类,是可以生成BusBaseObject中的字段配置到hbm文件中的。
不知道各位有没有遇到过类似问题,有没有解决办法。
这是类图:
build.xml配置:
- <target name="hibernatedoclet" depends="prepare" unless="hibernatedoclet.unnecessary"
- description="Generate Hibernate mapping files">
- <taskdef name="hibernatedoclet"
- classname="xdoclet.modules.hibernate.HibernateDocletTask"
- classpathref="xdoclet.classpath"/>
- <echo>generate hibernate files</echo>
- <mkdir dir="src/java/${module.name}"/>
- <if>
- <not><equals arg1="${module.name}" arg2="commons"/></not>
- <then>
- <hibernatedoclet destdir="${build.dir}/hbm"
- excludedtags="@version,@author" addedtags="@xdoclet-generated at ${TODAY}"
- force="${xdoclet.force}">
- <fileset dir="${src}" includes="**/model/*.java"/>
- <fileset dir="${src}/${module.name}" includes="**/model/*.java"/>
- <hibernate validatexml="true" version="3.0"/>
- </hibernatedoclet>
- </then>
- </if>
- </target>
生成的hbm文件如下:
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
- <hibernate-mapping
- >
- <class
- name="com.ed365.exam.model.ExamQuestion"
- table="EXAM_QUESTION"
- >
- <id
- name="examQuestionId"
- column="EXAM_QUESTION_ID"
- type="string"
- length="32"
- >
- <!-- The generator-class attribute of @hibernate.id is deprecated, use the @hibernate.generator tag instead -->
- <generator class="uuid">
- </generator>
- </id>
- <property
- name="grade"
- type="string"
- column="GRADE"
- length="32"
- not-null="true"
- >
- </property>
- <property
- name="subject"
- type="string"
- column="SUBJECT"
- length="32"
- not-null="true"
- >
- </property>
- <property
- name="section"
- type="string"
- column="SECTION"
- length="32"
- not-null="true"
- >
- </property>
- <property
- name="contentType"
- type="string"
- column="CONTENT_TYPE"
- length="32"
- not-null="true"
- >
- </property>
- <property
- name="questionKeyWords"
- type="string"
- column="QUESTION_KEYWORDS"
- length="1000"
- >
- </property>
- <property
- name="difficulty"
- type="string"
- column="DIFFICULTY"
- length="32"
- not-null="true"
- >
- </property>
- <property
- name="discrimination"
- type="string"
- column="DISCRIMINATION"
- length="32"
- not-null="true"
- >
- </property>
- <property
- name="cognition"
- type="string"
- column="COGNITION"
- length="32"
- not-null="true"
- >
- </property>
- <property
- name="claim"
- type="string"
- column="CLAIM"
- length="1000"
- >
- </property>
- <property
- name="reviser"
- type="string"
- column="REVISER"
- length="32"
- >
- </property>
- <property
- name="reviseDate"
- type="date"
- column="REVISE_DATE"
- >
- </property>
- <property
- name="parentId"
- type="string"
- column="PARENT_ID"
- length="32"
- >
- </property>
- <property
- name="issueScope"
- type="string"
- column="ISSUE_SCOPE"
- length="32"
- >
- </property>
- <property
- name="questionType"
- type="string"
- column="QUESTION_TYPE"
- length="32"
- not-null="true"
- >
- </property>
- <property
- name="questionContent"
- type="text"
- column="QUESTION_CONTENT"
- not-null="true"
- >
- </property>
- <property
- name="attachmentId"
- type="string"
- column="ATTACHMENT_ID"
- length="2000"
- >
- </property>
- </class>
- </hibernate-mapping>
问题补充:
因为要做自动化部署,不想每次用手动去改hbm文件或者手动去重新生成hbm文件。
问题补充:
我们开发是用eclipse部署,但是发布和每日构建是用ant自动编译的,目前build.xml已经写了很多代码,如果放弃不用,还得重头再来,而且用eclipse做发布和每日构建并不是很好的选择。
利用hibernatedoclet生成hbm文件遇到的问题20
现在项目中用ant hibernatedoclet自动生成pojo的hbm文件,生成简单的pojo很正常。如果一个类的继承有两层以上的话,只能生成父类的字段,祖父及以上类的字段无论如何都生成不了。
如ExamQuestion继承了Question,Question是一个抽象类,继承自BusBaseObject,在用ant hibernatedoclet生成hbm文件时,只能生产Question类中的字段配置,没有生成BusBaseObject中的字段配置。但是对于其它直接继承BusBaseObject的类,是可以生成BusBaseObject中的字段配置到hbm文件中的。
不知道各位有没有遇到过类似问题,有没有解决办法。
这是类图:
build.xml配置:
- <target name="hibernatedoclet" depends="prepare" unless="hibernatedoclet.unnecessary"
- description="Generate Hibernate mapping files">
- <taskdef name="hibernatedoclet"
- classname="xdoclet.modules.hibernate.HibernateDocletTask"
- classpathref="xdoclet.classpath"/>
- <echo>generate hibernate files</echo>
- <mkdir dir="src/java/${module.name}"/>
- <if>
- <not><equals arg1="${module.name}" arg2="commons"/></not>
- <then>
- <hibernatedoclet destdir="${build.dir}/hbm"
- excludedtags="@version,@author" addedtags="@xdoclet-generated at ${TODAY}"
- force="${xdoclet.force}">
- <fileset dir="${src}" includes="**/model/*.java"/>
- <fileset dir="${src}/${module.name}" includes="**/model/*.java"/>
- <hibernate validatexml="true" version="3.0"/>
- </hibernatedoclet>
- </then>
- </if>
- </target>
生成的hbm文件如下:
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
- <hibernate-mapping
- >
- <class
- name="com.ed365.exam.model.ExamQuestion"
- table="EXAM_QUESTION"
- >
- <id
- name="examQuestionId"
- column="EXAM_QUESTION_ID"
- type="string"
- length="32"
- >
- <!-- The generator-class attribute of @hibernate.id is deprecated, use the @hibernate.generator tag instead -->
- <generator class="uuid">
- </generator>
- </id>
- <property
- name="grade"
- type="string"
- column="GRADE"
- length="32"
- not-null="true"
- >
- </property>
- <property
- name="subject"
- type="string"
- column="SUBJECT"
- length="32"
- not-null="true"
- >
- </property>
- <property
- name="section"
- type="string"
- column="SECTION"
- length="32"
- not-null="true"
- >
- </property>
- <property
- name="contentType"
- type="string"
- column="CONTENT_TYPE"
- length="32"
- not-null="true"
- >
- </property>
- <property
- name="questionKeyWords"
- type="string"
- column="QUESTION_KEYWORDS"
- length="1000"
- >
- </property>
- <property
- name="difficulty"
- type="string"
- column="DIFFICULTY"
- length="32"
- not-null="true"
- >
- </property>
- <property
- name="discrimination"
- type="string"
- column="DISCRIMINATION"
- length="32"
- not-null="true"
- >
- </property>
- <property
- name="cognition"
- type="string"
- column="COGNITION"
- length="32"
- not-null="true"
- >
- </property>
- <property
- name="claim"
- type="string"
- column="CLAIM"
- length="1000"
- >
- </property>
- <property
- name="reviser"
- type="string"
- column="REVISER"
- length="32"
- >
- </property>
- <property
- name="reviseDate"
- type="date"
- column="REVISE_DATE"
- >
- </property>
- <property
- name="parentId"
- type="string"
- column="PARENT_ID"
- length="32"
- >
- </property>
- <property
- name="issueScope"
- type="string"
- column="ISSUE_SCOPE"
- length="32"
- >
- </property>
- <property
- name="questionType"
- type="string"
- column="QUESTION_TYPE"
- length="32"
- not-null="true"
- >
- </property>
- <property
- name="questionContent"
- type="text"
- column="QUESTION_CONTENT"
- not-null="true"
- >
- </property>
- <property
- name="attachmentId"
- type="string"
- column="ATTACHMENT_ID"
- length="2000"
- >
- </property>
- </class>
- </hibernate-mapping>
问题补充:
因为要做自动化部署,不想每次用手动去改hbm文件或者手动去重新生成hbm文件。
问题补充:
我们开发是用eclipse部署,但是发布和每日构建是用ant自动编译的,目前build.xml已经写了很多代码,如果放弃不用,还得重头再来,而且用eclipse做发布和每日构建并不是很好的选择。