1 2 Previous Next 24 Replies Latest reply on May 19, 2008 6:00 PM by Louie Liu

    Regarding EnversHibernateToolTask

    Louie Liu Newbie

      I am trying to generate the DDL using Envers Ant task EnversHibernateToolTask. I got the following error:

      INFO: Hibernate Validator 3.0.0.GA
      [hibernatetool] An exception occurred while running exporter #2:hbm2ddl (Generates database schema)
      [hibernatetool] To get the full stack trace run ant with -verbose
      [hibernatetool] org.hibernate.MappingException: Type not supported: org.hibernate.type.DateType

      Also, it looks like that the ant build task from Envers source package is not working.

      Please help. Thanks.

      Louie Liu

        • 1. Re: Regarding EnversHibernateToolTask
          Adam Warski Master

          Hello,

          there was a bug with dates, thanks for reporting!
          I've uploaded the fixed version here:
          http://www.jboss.org/envers/downloads/development/

          Adam

          • 2. Re: Regarding EnversHibernateToolTask
            Louie Liu Newbie

            Thanks for your help.

            The new jar did fix the previous issue. However, I got different error this time. Please see the error message:

            [INFO] [antrun:run {execution: wam.entity-audit}]
            [INFO] Executing tasks
            [hibernatetool] Executing Hibernate Tool with a JPA Configuration
            [hibernatetool] 1. task: hbm2ddl (Generates database schema)
            Apr 29, 2008 3:17:18 PM org.hibernate.cfg.annotations.Version
            INFO: Hibernate Annotations 3.3.0.GA
            Apr 29, 2008 3:17:18 PM org.hibernate.cfg.Environment
            INFO: Hibernate 3.2.6
            Apr 29, 2008 3:17:18 PM org.hibernate.cfg.Environment
            INFO: hibernate.properties not found
            Apr 29, 2008 3:17:18 PM org.hibernate.cfg.Environment buildBytecodeProvider
            INFO: Bytecode provider name : cglib
            Apr 29, 2008 3:17:18 PM org.hibernate.cfg.Environment
            INFO: using JDK 1.4 java.sql.Timestamp handling
            Apr 29, 2008 3:17:18 PM org.hibernate.ejb.Version
            INFO: Hibernate EntityManager 3.3.1.GA
            Apr 29, 2008 3:17:19 PM org.hibernate.cfg.AnnotationBinder bindClass
            INFO: Binding entity from annotated class: com.westernasset.employee.Office
            Apr 29, 2008 3:17:19 PM org.hibernate.cfg.annotations.EntityBinder bindTable
            INFO: Bind entity com.westernasset.employee.Office on table office
            Apr 29, 2008 3:17:19 PM org.hibernate.cfg.AnnotationBinder bindClass
            INFO: Binding entity from annotated class: com.westernasset.employee.Employee
            Apr 29, 2008 3:17:19 PM org.hibernate.cfg.annotations.EntityBinder bindTable
            INFO: Bind entity com.westernasset.employee.Employee on table employee
            Apr 29, 2008 3:17:19 PM org.hibernate.cfg.AnnotationBinder bindClass
            INFO: Binding entity from annotated class: com.westernasset.employee.EmployeeGroup
            Apr 29, 2008 3:17:19 PM org.hibernate.cfg.annotations.EntityBinder bindTable
            INFO: Bind entity com.westernasset.employee.EmployeeGroup on table employee_group
            Apr 29, 2008 3:17:19 PM org.hibernate.cfg.AnnotationBinder bindClass
            INFO: Binding entity from annotated class: com.westernasset.employee.EmployeeGroupMember
            Apr 29, 2008 3:17:19 PM org.hibernate.cfg.annotations.EntityBinder bindTable
            INFO: Bind entity com.westernasset.employee.EmployeeGroupMember on table employee_group_member
            Apr 29, 2008 3:17:19 PM org.hibernate.cfg.annotations.CollectionBinder bindOneToManySecondPass
            INFO: Mapping collection: com.westernasset.employee.Employee.groups -> employee_group_member
            Apr 29, 2008 3:17:19 PM org.hibernate.cfg.annotations.CollectionBinder bindOneToManySecondPass
            INFO: Mapping collection: com.westernasset.employee.EmployeeGroup.members -> employee_group_member
            Apr 29, 2008 3:17:19 PM org.hibernate.validator.Version
            INFO: Hibernate Validator 3.0.0.GA
            [hibernatetool] An exception occurred while running exporter #2:hbm2ddl (Generates database schema)
            [hibernatetool] To get the full stack trace run ant with -verbose
            [hibernatetool] org.hibernate.MappingException: Type not supported: org.hibernate.type.CustomType
            [INFO] ------------------------------------------------------------------------
            [ERROR] BUILD ERROR
            [INFO] ------------------------------------------------------------------------
            [INFO] Error executing ant tasks

            Embedded error: org.hibernate.MappingException: Type not supported: org.hibernate.type.CustomType

            I am using Maven to run this ant task (maven 2.0.9 + jdk1.6.0).

            Thanks for your help.

            Louie

            • 3. Re: Regarding EnversHibernateToolTask
              Adam Warski Master

              Hello,

              and what properties are you mapping in your entities - what are their classes? I see that hibernate is reporting a "custom type", and I'm wondering which JPA type it may be :)

              Adam

              • 4. Re: Regarding EnversHibernateToolTask
                Louie Liu Newbie

                Thanks,

                It looks like coming from your version table since I run hibernate tool generate the schema based on my entity without any issue. Please find all those four classes I used in this build:

                import java.util.Date;
                import java.util.GregorianCalendar;
                import java.util.Set;
                
                import javax.mail.internet.AddressException;
                import javax.mail.internet.InternetAddress;
                import javax.persistence.Column;
                import javax.persistence.Entity;
                import javax.persistence.EnumType;
                import javax.persistence.Enumerated;
                import javax.persistence.GeneratedValue;
                import javax.persistence.Id;
                import javax.persistence.ManyToOne;
                import javax.persistence.OneToMany;
                import javax.persistence.SequenceGenerator;
                import javax.persistence.Temporal;
                import javax.persistence.TemporalType;
                
                import org.hibernate.annotations.ForeignKey;
                import org.jboss.envers.Versioned;
                
                import net.sf.oval.constraint.Assert;
                import net.sf.oval.guard.Guarded;
                
                @Entity
                @Versioned
                @Guarded(applyFieldConstraintsToSetters = true)
                public class Employee {
                 /** Primary key id */
                 @Id
                 @SequenceGenerator(name = "Employee", sequenceName = "employee_id")
                 @GeneratedValue(generator="Employee")
                 private int id;
                
                 /** <a href="http://en.wikipedia.org/wiki/Given_name">First name</a> */
                 @Column(length=30, nullable=false)
                 private String firstName;
                
                 /** <a href="http://en.wikipedia.org/wiki/Surname">Last name</a> */
                 @Column(length=30, nullable=false)
                 private String lastName;
                
                 /** <a href="http://en.wikipedia.org/wiki/Nickname">Nickname</a> */
                 @Column(length=30)
                 private String nickname;
                
                 /** <a href="http://en.wikipedia.org/wiki/Personal_name">Full name</a> */
                 @Column(length=100, nullable=false)
                 private String fullName;
                
                 /** Employee's Office location */
                 @ManyToOne
                 @ForeignKey(name="office")
                 private Office office;
                
                 /** Employee's <a href="http://en.wikipedia.org/wiki/E-mail_address">Email Address</a> */
                 @Column(length=80)
                 private String emailAddress;
                
                 @Column(length=30)
                 private String userName;
                
                 /** Hire date */
                 @Column(nullable=false)
                 @Temporal(TemporalType.DATE)
                 @Assert(expr = "_value.before(_this.terminationDate)", lang = "groovy")
                 private Date hireDate = new Date();
                
                 /** Termination date */
                 @Temporal(TemporalType.DATE)
                 @Assert(expr = "_value.after(_this.hireDate)", lang = "groovy")
                 private Date terminationDate = new GregorianCalendar(9999, 11, 31).getTime();
                
                 /** Employee Groups */
                 @OneToMany(mappedBy="memberEmployee")
                 private Set<EmployeeGroupMember> groups;
                
                
                 /** Employee Status */
                 public enum Status
                 {
                 /** Full Time Employee */
                 FTE,
                 /** Part-time Employee */
                 PTE,
                 /** Temporary Contract Employee */
                 TCE
                 };
                
                 /** Employment Status */
                 @Enumerated(EnumType.STRING)
                 @Column(length = 3, nullable = false)
                 private Status status;
                
                 /**
                 * @return the id
                 */
                 public int getId () {
                 return id;
                 }
                
                 /**
                 * @return the firstName
                 */
                 public String getFirstName () {
                 return firstName;
                 }
                
                 /**
                 * @param firstName the firstName to set
                 */
                 public void setFirstName (final String firstName) {
                 this.firstName = firstName;
                 }
                
                 /**
                 * @return the lastName
                 */
                 public String getLastName () {
                 return lastName;
                 }
                
                 /**
                 * @param lastName the lastName to set
                 */
                 public void setLastName (final String lastName) {
                 this.lastName = lastName;
                 }
                
                 /**
                 * @return the nickname
                 */
                 public String getNickname () {
                 return nickname;
                 }
                
                 /**
                 * @param nickname the nickname to set
                 */
                 public void setNickname (final String nickname) {
                 this.nickname = nickname;
                 }
                
                 /**
                 * @return the fullName
                 */
                 public String getFullName () {
                 return fullName;
                 }
                
                 /**
                 * @param fullName the fullName to set
                 */
                 public void setFullName (final String fullName) {
                 this.fullName = fullName;
                 }
                
                 /**
                 * @return the office
                 */
                 public Office getOffice () {
                 return office;
                 }
                
                 /**
                 * @param office the office to set
                 */
                 public void setOffice (final Office office) {
                 this.office = office;
                 }
                
                 /**
                 * @return the emailAddress
                 */
                 public String getEmailAddress () {
                 return emailAddress;
                 }
                
                 /**
                 * @param emailAddress the emailAddress to set
                 */
                 public void setEmailAddress (final String emailAddress) throws AddressException {
                 // Validate that the e-mail address is RFC822 compliant...
                 final InternetAddress validAddress = new InternetAddress(emailAddress);
                 assert null != validAddress;
                
                 this.emailAddress = emailAddress;
                 }
                
                 /**
                 * @return the hireDate
                 */
                 public Date getHireDate () {
                 return hireDate;
                 }
                
                 /**
                 * @param hireDate the hireDate to set
                 */
                 public void setHireDate (final Date hireDate) {
                 this.hireDate = hireDate;
                 }
                
                 /**
                 * @return the terminationDate
                 */
                 public Date getTerminationDate () {
                 return terminationDate;
                 }
                
                 /**
                 * @param terminationDate the terminationDate to set
                 */
                 public void setTerminationDate (final Date terminationDate) {
                 this.terminationDate = terminationDate;
                 }
                
                 /**
                 * @return the status
                 */
                 public Status getStatus () {
                 return status;
                 }
                
                 /**
                 * @param status the status to set
                 */
                 public void setStatus (final Status status) {
                 this.status = status;
                 }
                
                 public String getUserName() {
                 return userName;
                 }
                
                 public void setUserName(String userName) {
                 this.userName = userName;
                 }
                
                 public Set<EmployeeGroupMember> getGroups() {
                 return groups;
                 }
                
                 public void setGroups(Set<EmployeeGroupMember> groups) {
                 this.groups = groups;
                 }
                
                 public void setId(int id) {
                 this.id = id;
                 }
                }
                


                
                import java.util.Collections;
                import java.util.Date;
                import java.util.HashSet;
                import java.util.Set;
                
                import javax.mail.internet.AddressException;
                import javax.mail.internet.InternetAddress;
                import javax.persistence.Column;
                import javax.persistence.Entity;
                import javax.persistence.GeneratedValue;
                import javax.persistence.Id;
                import javax.persistence.OneToMany;
                import javax.persistence.SequenceGenerator;
                import javax.persistence.Table;
                import javax.persistence.UniqueConstraint;
                
                import org.jboss.envers.Versioned;
                
                import net.sf.oval.guard.Guarded;
                
                @Entity
                @Versioned
                @Table(uniqueConstraints = @UniqueConstraint(columnNames = {"category", "label"}))
                @Guarded(applyFieldConstraintsToSetters = true)
                public class EmployeeGroup {
                 /** Primary key id */
                 @Id
                 @SequenceGenerator(name = "EmployeeGroup", sequenceName = "employee_group_id")
                 @GeneratedValue(generator="EmployeeGroup")
                 private int id;
                
                 /** Employee Group Category. This allows the Label to be reused for different categories. */
                 @Column(length=50, nullable=false)
                 private String category;
                
                 /** Employee Group Label */
                 @Column(length=50, nullable=false)
                 private String label;
                
                 /** <a href="http://en.wikipedia.org/wiki/Distribution_list">Distribution list</a> for the group */
                 @Column(length=80)
                 private String emailAddress;
                
                 /** Employee Group Members */
                 @OneToMany(mappedBy="employeeGroup")
                 private Set<EmployeeGroupMember> members;
                
                 /**
                 * @return the id
                 */
                 public int getId () {
                 return id;
                 }
                
                 /**
                 * @return the category
                 */
                 public String getCategory () {
                 return category;
                 }
                
                 /**
                 * @param category the category to set
                 */
                 public void setCategory (final String category) {
                 this.category = category;
                 }
                
                 /**
                 * @return the label
                 */
                 public String getLabel () {
                 return label;
                 }
                
                 /**
                 * @param label the label to set
                 */
                 public void setLabel (final String label) {
                 this.label = label;
                 }
                
                 /**
                 * @return the emailAddress
                 */
                 public String getEmailAddress () {
                 return emailAddress;
                 }
                
                 /**
                 * @param emailAddress the emailAddress to set
                 */
                 public void setEmailAddress (final String emailAddress) throws AddressException {
                 // Validate that the e-mail address is RFC822 compliant...
                 final InternetAddress validAddress = new InternetAddress(emailAddress);
                 assert null != validAddress;
                
                 this.emailAddress = emailAddress;
                 }
                
                 /**
                 * Tells the subset of members active for a specified date.
                 * @return the subset of members active as of the effectiveDate
                 */
                 public Set<EmployeeGroupMember> getMembers (final Date effectiveDate) {
                 final Set<EmployeeGroupMember> membersAsOfDate = new HashSet<EmployeeGroupMember>(
                 members.size());
                 for (final EmployeeGroupMember member : members) {
                 if (member.isActive(effectiveDate)) {
                 membersAsOfDate.add(member);
                 }
                 }
                 return Collections.unmodifiableSet(membersAsOfDate);
                 }
                
                
                 /**
                 * @return the members
                 */
                 public Set<EmployeeGroupMember> getMembers () {
                 return members;
                 }
                
                 /**
                 * @param members the members to set
                 */
                 public void setMembers (final Set<EmployeeGroupMember> members) {
                 this.members = members;
                 }
                
                 public void setId(int id) {
                 this.id = id;
                 }
                
                }
                
                import java.util.Date;
                import java.util.GregorianCalendar;
                
                import javax.persistence.Column;
                import javax.persistence.Entity;
                import javax.persistence.GeneratedValue;
                import javax.persistence.Id;
                import javax.persistence.ManyToOne;
                import javax.persistence.SequenceGenerator;
                import javax.persistence.Temporal;
                import javax.persistence.TemporalType;
                
                import org.jboss.envers.Versioned;
                
                import net.sf.oval.constraint.Assert;
                import net.sf.oval.guard.Guarded;
                
                
                @Entity
                @Versioned
                @Guarded(applyFieldConstraintsToSetters = true)
                public class EmployeeGroupMember {
                 /** Primary key id */
                 @Id
                 @SequenceGenerator(name = "EmployeeGroupMember", sequenceName = "employee_group_member_id")
                 @GeneratedValue(generator="EmployeeGroupMember")
                 private int id;
                
                 /** Employee Group */
                 @ManyToOne(optional = false)
                 private EmployeeGroup employeeGroup;
                
                 /** Employee (member) */
                 @ManyToOne(optional = false)
                 private Employee memberEmployee;
                
                 /** First day that the record is active. Record is active between the begin and end dates. */
                 @Column(nullable=false)
                 @Temporal(TemporalType.DATE)
                 @Assert(expr="_value.before(_this.endDate)", lang = "groovy")
                 private Date beginDate = new Date();
                
                 /** Last day that the record is active. Record is active between the begin and end dates. */
                 @Temporal(TemporalType.DATE)
                 @Assert(expr="_value.after(_this.beginDate)", lang = "groovy")
                 private Date endDate = new GregorianCalendar(9999, 11, 31).getTime();
                
                 /**
                 * @return the id
                 */
                 public int getId () {
                 return id;
                 }
                
                 /**
                 * @return the employeeGroup
                 */
                 public EmployeeGroup getEmployeeGroup() {
                 return employeeGroup;
                 }
                
                 /**
                 * @param employeeGroup
                 */
                 public void setEmployeeGroup(EmployeeGroup employeeGroup) {
                 this.employeeGroup = employeeGroup;
                 }
                
                 /**
                 * @return the memberEmployee
                 */
                 public Employee getMemberEmployee () {
                 return memberEmployee;
                 }
                
                 /**
                 * @param memberEmployee the memberEmployee to set
                 */
                 public void setMemberEmployee (final Employee memberEmployee) {
                 this.memberEmployee = memberEmployee;
                 }
                
                 /**
                 * @return the beginDate
                 */
                 public Date getBeginDate () {
                 return beginDate;
                 }
                
                 /**
                 * @param beginDate the beginDate to set
                 */
                 public void setBeginDate (final Date beginDate) {
                 this.beginDate = beginDate;
                 }
                
                 /**
                 * @return the endDate
                 */
                 public Date getEndDate () {
                 return endDate;
                 }
                
                 /**
                 * @param endDate the endDate to set
                 */
                 public void setEndDate (final Date endDate) {
                 this.endDate = endDate;
                 }
                
                 /**
                 * Tells if the membership was active as of the effective date.
                 * @param effectiveDate date to test membership
                 * @return true if the effectiveDate is between (inclusive) the begin and end dates.
                 */
                 public boolean isActive (final Date effectiveDate) {
                 return (effectiveDate.after(beginDate) || effectiveDate
                 .equals(beginDate))
                 && (effectiveDate.before(endDate) || effectiveDate
                 .equals(endDate));
                 }
                
                 public void setId(int id) {
                 this.id = id;
                 }
                }
                
                
                import java.util.Date;
                import java.util.GregorianCalendar;
                import java.util.TimeZone;
                
                import javax.persistence.Column;
                import javax.persistence.Entity;
                import javax.persistence.GeneratedValue;
                import javax.persistence.Id;
                import javax.persistence.SequenceGenerator;
                import javax.persistence.Temporal;
                import javax.persistence.TemporalType;
                import javax.persistence.Transient;
                
                import org.jboss.envers.Versioned;
                
                import net.sf.oval.constraint.Assert;
                
                @Entity
                @Versioned
                public class Office {
                 /** Primary key id */
                 @Id
                 @SequenceGenerator(name = "Office", sequenceName = "office_id")
                 @GeneratedValue(generator="Office")
                 private int id;
                
                 /** Office Label */
                 @Column(length=20, nullable=false, unique=true)
                 private String label;
                
                 /** <a href="http://en.wikipedia.org/wiki/Time_zone">Time zone</a> */
                 @Column(length=30, nullable=false)
                 private String timeZoneId;
                
                 /** Internal TimeZone defined by timeZoneID */
                 @Transient
                 private TimeZone timeZone;
                
                 /** First day that the record is active. Record is active between the begin and end dates. */
                 @Column(nullable=false)
                 @Temporal(TemporalType.DATE)
                 @Assert(expr = "_value.before(_this.endDate)", lang = "groovy")
                 private Date beginDate = new Date();
                
                 /** Last day that the record is active. Record is active between the begin and end dates. */
                 @Column(nullable=false)
                 @Temporal(TemporalType.DATE)
                 @Assert(expr = "_value.after(_this.beginDate)", lang = "groovy")
                 private Date endDate = new GregorianCalendar(9999, 11, 31).getTime();
                
                 /**
                 * @return the id
                 */
                 public int getId () {
                 return id;
                 }
                
                 /**
                 * @return the label
                 */
                 public String getLabel () {
                 return label;
                 }
                
                 /**
                 * @param label the label to set
                 */
                 public void setLabel (String label) {
                 this.label = label;
                 }
                
                 /**
                 * @return the timeZoneId
                 */
                 public String getTimeZoneId () {
                 return timeZoneId;
                 }
                
                 /**
                 * @param timeZoneId the timeZoneId to set
                 */
                 public void setTimeZoneId (final String timeZoneId) {
                 this.timeZone = TimeZone.getTimeZone(timeZoneId);
                 this.timeZoneId = this.timeZone.getID();
                 }
                
                 /**
                 * @return the timeZone
                 */
                 public TimeZone getTimeZone () {
                 if (null == this.timeZone && null != this.timeZoneId)
                 {
                 this.timeZone = TimeZone.getTimeZone(this.timeZoneId);
                 }
                 return timeZone;
                 }
                
                 /**
                 * Record is active between the begin and end dates.
                 * @return the beginDate
                 */
                 public Date getBeginDate () {
                 return beginDate;
                 }
                
                 /**
                 * Record is active between the begin and end dates.
                 * @param beginDate the beginDate to set
                 */
                 public void setBeginDate (final Date beginDate) {
                 this.beginDate = beginDate;
                 }
                
                 /**
                 * Record is active between the begin and end dates.
                 * @return the endDate
                 */
                 public Date getEndDate () {
                 return endDate;
                 }
                
                 /**
                 * Record is active between the begin and end dates.
                 * @param endDate the endDate to set
                 */
                 public void setEndDate (final Date endDate) {
                 this.endDate = endDate;
                 }
                
                 public void setId(int id) {
                 this.id = id;
                 }
                }
                
                


                Please help. Thanks a lot.

                Louie

                • 5. Re: Regarding EnversHibernateToolTask
                  Louie Liu Newbie

                  Also, here are some more error message:

                  INFO: Bind entity com.westernasset.employee.EmployeeGroup on table employee_group
                  Apr 30, 2008 9:04:16 AM org.hibernate.cfg.AnnotationBinder bindClass
                  INFO: Binding entity from annotated class: com.westernasset.employee.EmployeeGroupMember
                  Apr 30, 2008 9:04:16 AM org.hibernate.cfg.annotations.EntityBinder bindTable
                  INFO: Bind entity com.westernasset.employee.EmployeeGroupMember on table employee_group_member
                  Apr 30, 2008 9:04:17 AM org.hibernate.cfg.annotations.CollectionBinder bindOneToManySecondPass
                  INFO: Mapping collection: com.westernasset.employee.Employee.groups -> employee_group_member
                  Apr 30, 2008 9:04:17 AM org.hibernate.cfg.annotations.CollectionBinder bindOneToManySecondPass
                  INFO: Mapping collection: com.westernasset.employee.EmployeeGroup.members -> employee_group_member
                  Apr 30, 2008 9:04:17 AM org.hibernate.validator.Version
                  INFO: Hibernate Validator 3.0.0.GA
                  [hibernatetool] An exception occurred while running exporter #2:hbm2ddl (Generates database schema)
                  [hibernatetool] To get the full stack trace run ant with -verbose
                  [hibernatetool] org.hibernate.MappingException: Type not supported: org.hibernate.type.CustomType
                  [INFO] ------------------------------------------------------------------------
                  [ERROR] BUILD ERROR
                  [INFO] ------------------------------------------------------------------------
                  [INFO] Error executing ant tasks

                  Embedded error: org.hibernate.MappingException: Type not supported: org.hibernate.type.CustomType
                  [INFO] ------------------------------------------------------------------------
                  [INFO] Trace
                  org.apache.maven.lifecycle.LifecycleExecutionException: Error executing ant tasks
                  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor
                  .java:583)
                  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifec
                  ycleExecutor.java:499)
                  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.
                  java:478)
                  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultL
                  ifecycleExecutor.java:330)
                  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleE
                  xecutor.java:291)
                  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java
                  :142)
                  at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
                  at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
                  at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  at java.lang.reflect.Method.invoke(Method.java:597)
                  at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
                  at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
                  at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
                  at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
                  Caused by: org.apache.maven.plugin.MojoExecutionException: Error executing ant tasks
                  at org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:114)
                  at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:83)
                  at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
                  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor
                  .java:558)
                  ... 16 more
                  Caused by: org.hibernate.MappingException: Type not supported: org.hibernate.type.CustomType
                  at org.hibernate.tool.ant.HibernateToolTask.reportException(HibernateToolTask.java:226)
                  at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:189)
                  at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
                  at org.apache.tools.ant.Task.perform(Task.java:364)
                  at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:64)
                  at net.sf.antcontrib.logic.IfTask.execute(IfTask.java:197)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  at java.lang.reflect.Method.invoke(Method.java:597)
                  at org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:123)
                  at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
                  at org.apache.tools.ant.Task.perform(Task.java:364)
                  at org.apache.tools.ant.Target.execute(Target.java:341)
                  at org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:108)
                  ... 19 more
                  Caused by: org.hibernate.MappingException: Type not supported: org.hibernate.type.CustomType
                  at org.jboss.envers.metadata.VersionsMetadataGenerator.addProperties(VersionsMetadataGenerat
                  or.java:299)
                  at org.jboss.envers.metadata.VersionsMetadataGenerator.generateFirstPass(VersionsMetadataGen
                  erator.java:367)
                  at org.jboss.envers.configuration.VersionsConfiguration.configure(VersionsConfiguration.java
                  :189)
                  at org.jboss.envers.configuration.VersionsConfiguration.getFor(VersionsConfiguration.java:25
                  1)
                  at org.jboss.envers.ant.JPAConfigurationTaskWithEnvers.doConfiguration(JPAConfigurationTaskW
                  ithEnvers.java:33)
                  at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
                  at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:302)
                  at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45)
                  at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)
                  ... 32 more
                  [INFO] ------------------------------------------------------------------------
                  [INFO] Total time: 7 seconds
                  [INFO] Finished at: Wed Apr 30 09:04:17 PDT 2008
                  [INFO] Final Memory: 21M/38M
                  [INFO] ------------------------------------------------------------------------

                  Looks like it happened at the following:

                  org.jboss.envers.metadata.VersionsMetadataGenerator.addProperties(VersionsMetadataGenerat
                  or.java:299)

                  location.

                  Thanks.

                  Louie



















                  • 6. Re: Regarding EnversHibernateToolTask
                    Adam Warski Master

                    Hello,

                    just uploaded the fixed version - http://www.jboss.org/envers/downloads/development/

                    Turned out that Enums are treated as a CustomType, differently from dates, serializables, integers, etc.

                    Sorry for the inconvenience and waiting for future feedback :)

                    Adam

                    • 7. Re: Regarding EnversHibernateToolTask
                      Louie Liu Newbie

                      This time, it works. Thanks for your help.

                      Louie

                      • 8. Re: Regarding EnversHibernateToolTask
                        Louie Liu Newbie

                        Sorry I would like to report another bug. It is failed on uni-direction one-to-many relationship. For example, this tool is failed for this entity:

                        package com.westernasset.calendar;
                        
                        import java.util.Date;
                        import java.util.Set;
                        import java.util.SortedSet;
                        import java.util.TreeSet;
                        
                        import javax.persistence.Column;
                        import javax.persistence.Entity;
                        import javax.persistence.EnumType;
                        import javax.persistence.Enumerated;
                        import javax.persistence.FetchType;
                        import javax.persistence.GeneratedValue;
                        import javax.persistence.Id;
                        import javax.persistence.ManyToOne;
                        import javax.persistence.NamedQueries;
                        import javax.persistence.NamedQuery;
                        import javax.persistence.OneToMany;
                        import javax.persistence.SequenceGenerator;
                        import javax.persistence.Transient;
                        
                        import net.sf.oval.guard.Guarded;
                        
                        import org.hibernate.annotations.ForeignKey;
                        import org.jboss.envers.Versioned;
                        
                        /**
                         * A Business Calendar is a set of Business Dates. A Business Calendar can be
                         * adjusted by a Holiday Calendar. An example might be a month-end calendar.
                         *
                         * @author awhitford
                         * @see <a href="http://en.wikipedia.org/wiki/4-4-5_Calendar">4-4-5 Calendar</a>
                         */
                        @Entity
                        @NamedQueries({
                         @NamedQuery(name="BusinessCalendar.findById", query="select b from BusinessCalendar b where b.id = :id"),
                         @NamedQuery(name="BusinessCalendar.findByName", query="select b from BusinessCalendar b where b.name = :name"),
                         @NamedQuery(name="BusinessCalendar.findAll", query="select b from BusinessCalendar b")
                        })
                        @Guarded(applyFieldConstraintsToSetters = true)
                        @Versioned
                        public class BusinessCalendar {
                        
                         /** Primary key id */
                         @Id
                         @SequenceGenerator(name = "BusinessCalendar", sequenceName = "business_calendar_id")
                         @GeneratedValue(generator = "BusinessCalendar")
                         private int id;
                        
                         @Column(length = 40, nullable = false, unique = true)
                         private String name;
                        
                         @OneToMany(fetch = FetchType.EAGER)
                         private Set<BusinessCalendarDate> dates;
                        
                         @ManyToOne(fetch = FetchType.EAGER)
                         @ForeignKey(name = "FK_business_cal_holiday_cal")
                         private HolidayCalendar holidays;
                        
                         /** Holiday Handler Type */
                         @Enumerated(EnumType.STRING)
                         @Column(length = 30)
                         private HolidayHandlerType holidayHandlerType;
                        
                         @Transient
                         private transient DateCalculator dateCalculator;
                        
                         protected DateCalculator getDateCalculator () {
                         if (null == this.dateCalculator) {
                         this.dateCalculator = new DateCalculator(holidays, holidayHandlerType);
                         }
                         return this.dateCalculator;
                         }
                        
                         /**
                         * @return the id
                         */
                         public int getId () {
                         return id;
                         }
                        
                         /**
                         * @param id
                         * the id to set
                         */
                         public void setId (final int id) {
                         this.id = id;
                         }
                        
                         /**
                         * @return the name
                         */
                         public String getName () {
                         return name;
                         }
                        
                         /**
                         * @param name
                         * the name to set
                         */
                         public void setName (final String name) {
                         this.name = name;
                         }
                        
                         /**
                         * @return the dates
                         */
                         public Set<BusinessCalendarDate> getDates () {
                         return dates;
                         }
                        
                         /**
                         * @param dates
                         * the dates to set
                         */
                         public void setDates (final Set<BusinessCalendarDate> dates) {
                         this.dates = dates;
                         }
                        
                         /**
                         * @return the holidays
                         */
                         public HolidayCalendar getHolidays () {
                         return holidays;
                         }
                        
                         /**
                         * @param holidays
                         * the holidays to set
                         */
                         public void setHolidays (final HolidayCalendar holidays) {
                         if (this.holidays != holidays) {
                         this.dateCalculator = null;
                         this.holidays = holidays;
                         }
                         }
                        
                         /**
                         * @return the holidayHandlerType
                         */
                         public HolidayHandlerType getHolidayHandlerType () {
                         return holidayHandlerType;
                         }
                        
                         /**
                         * @param holidayHandlerType
                         * the holidayHandlerType to set
                         */
                         public void setHolidayHandlerType (
                         final HolidayHandlerType holidayHandlerType) {
                         if (this.holidayHandlerType != holidayHandlerType) {
                         this.dateCalculator = null;
                         this.holidayHandlerType = holidayHandlerType;
                         }
                         }
                        
                         /**
                         * Get the dates between a min and max date range.
                         *
                         * @param minDate
                         * minimum date (inclusive) of range, or null if no minimum
                         * @param maxDate
                         * maximum date (inclusive) of range, or null if no maximum
                         * @return A sorted set of dates that fit between the minimum and maximum
                         * dates, inclusively. Note that the set may be empty.
                         */
                         public SortedSet<Date> createDateRange (final Date minDate, final Date maxDate) {
                         // Minimum should precede (or equal) the Maximum...
                         assert null == minDate || null == maxDate
                         || minDate.compareTo(maxDate) <= 0;
                        
                         final SortedSet<Date> dates = new TreeSet<Date>();
                         for (final BusinessCalendarDate bcd : this.dates) {
                         final Date date = bcd.getDate();
                         if ((null == minDate || minDate.compareTo(date) <= 0)
                         && (null == maxDate || maxDate.compareTo(date) >= 0)) {
                         dates.add(date);
                         }
                         }
                         return dates;
                         }
                        
                         /**
                         * Find the next business date after the given date.
                         *
                         * @param date
                         * the date
                         * @return The next business date, adjusting for weekends and holidays. Null
                         * may be returned if the date exceeds the last known business date.
                         * @TODO Java 1.6 provides a NavigableSet.higher function!!!
                         */
                         public Date nextDate (final Date date) {
                         final SortedSet<Date> nextDates = createDateRange(date, null);
                         nextDates.remove(date);
                         return nextDates.isEmpty() ? null : this.getDateCalculator()
                         .setCurrentBusinessDate(nextDates.first());
                         }
                        
                         /**
                         * Find the previous business date after the given date.
                         *
                         * @param date
                         * the date
                         * @return The previous business date, adjusting for weekends and holidays.
                         * Null may be returned if the date precedes the first known
                         * business date.
                         * @TODO Java 1.6 provides a NavigableSet.lower function!!!
                         */
                         public Date previousDate (final Date date) {
                         final SortedSet<Date> prevDates = createDateRange(null, date);
                         prevDates.remove(date);
                         return prevDates.isEmpty() ? null : this.getDateCalculator()
                         .setCurrentBusinessDate(prevDates.last());
                         }
                        
                         /**
                         * Is the date a business date? Note that the Business Calendar is adjusted
                         * for weekends and holidays, so the date comparison is ultimately against a
                         * possibly adjusted date.
                         *
                         * @param date date to test
                         * @return true if the date matches a business date, false otherwise.
                         */
                         public boolean isBusinessDate (final Date date) {
                         return createActualDates().contains(date);
                         }
                        
                         public SortedSet<Date> createActualDates () {
                         final SortedSet<Date> dates = new TreeSet<Date>();
                         for (final BusinessCalendarDate bcd : this.dates) {
                         final Date date = bcd.getDate();
                         dates.add(this.getDateCalculator().setCurrentBusinessDate(date));
                         }
                         return dates;
                         }
                        }
                        


                        Here is the error message from maven build:

                        
                        May 5, 2008 10:50:58 AM org.hibernate.validator.Version <clinit>
                        INFO: Hibernate Validator 3.0.0.GA
                        entityName=com.westernasset.calendar.BusinessCalendar
                        Property=org.hibernate.mapping.Property(dates)
                        mapper=org.jboss.envers.mapper.MultiPropertyMapper@293b53
                        idMappers={com.westernasset.calendar.HolidayCalendar=org.jboss.envers.metadata.data.IdMappingData@f5
                        e814, com.westernasset.calendar.Holiday=org.jboss.envers.metadata.data.IdMappingData@5789f3, com.wes
                        ternasset.calendar.BusinessCalendarDate=org.jboss.envers.metadata.data.IdMappingData@121ea24, com.we
                        sternasset.calendar.BusinessCalendar=org.jboss.envers.metadata.data.IdMappingData@192e317}
                        [hibernatetool] An exception occurred while running exporter #2:hbm2ddl (Generates database schema)
                        [hibernatetool] To get the full stack trace run ant with -verbose
                        [hibernatetool] java.lang.ClassCastException: org.hibernate.mapping.ManyToOne cannot be cast to org.
                        hibernate.mapping.OneToMany
                        [INFO] ------------------------------------------------------------------------
                        [ERROR] BUILD ERROR
                        [INFO] ------------------------------------------------------------------------
                        [INFO] Error executing ant tasks
                        
                        Embedded error: java.lang.ClassCastException: org.hibernate.mapping.ManyToOne cannot be cast to org.
                        hibernate.mapping.OneToMany
                        [INFO] ------------------------------------------------------------------------
                        [INFO] Trace
                        org.apache.maven.lifecycle.LifecycleExecutionException: Error executing ant tasks
                         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor
                        .java:583)
                         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifec
                        ycleExecutor.java:499)
                         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.
                        java:478)
                         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultL
                        ifecycleExecutor.java:330)
                         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleE
                        xecutor.java:291)
                         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java
                        :142)
                         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
                         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
                         at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
                         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                         at java.lang.reflect.Method.invoke(Method.java:597)
                         at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
                         at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
                         at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
                         at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
                        Caused by: org.apache.maven.plugin.MojoExecutionException: Error executing ant tasks
                         at org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:114)
                         at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:83)
                         at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
                         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor
                        .java:558)
                         ... 16 more
                        Caused by: java.lang.ClassCastException: org.hibernate.mapping.ManyToOne cannot be cast to org.hiber
                        nate.mapping.OneToMany
                         at org.hibernate.tool.ant.HibernateToolTask.reportException(HibernateToolTask.java:226)
                         at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:189)
                         at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
                         at org.apache.tools.ant.Task.perform(Task.java:364)
                         at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:64)
                         at net.sf.antcontrib.logic.IfTask.execute(IfTask.java:197)
                         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                         at java.lang.reflect.Method.invoke(Method.java:597)
                         at org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:123)
                         at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
                         at org.apache.tools.ant.Task.perform(Task.java:364)
                         at org.apache.tools.ant.Target.execute(Target.java:341)
                         at org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:108)
                         ... 19 more
                        Caused by: java.lang.ClassCastException: org.hibernate.mapping.ManyToOne cannot be cast to org.hiber
                        nate.mapping.OneToMany
                         at org.jboss.envers.metadata.VersionsMetadataGenerator.getMappedBy(VersionsMetadataGenerator
                        .java:221)
                         at org.jboss.envers.metadata.VersionsMetadataGenerator.addOneToMany(VersionsMetadataGenerato
                        r.java:247)
                         at org.jboss.envers.metadata.VersionsMetadataGenerator.addProperties(VersionsMetadataGenerat
                        or.java:332)
                         at org.jboss.envers.metadata.VersionsMetadataGenerator.generateSecondPass(VersionsMetadataGe
                        nerator.java:418)
                         at org.jboss.envers.configuration.VersionsConfiguration.configure(VersionsConfiguration.java
                        :202)
                         at org.jboss.envers.configuration.VersionsConfiguration.getFor(VersionsConfiguration.java:25
                        1)
                         at org.jboss.envers.ant.JPAConfigurationTaskWithEnvers.doConfiguration(JPAConfigurationTaskW
                        ithEnvers.java:33)
                         at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
                         at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:302)
                         at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45)
                         at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)
                         ... 32 more
                        


                        • 9. Re: Regarding EnversHibernateToolTask
                          Louie Liu Newbie

                          Another bug:

                          at org.jboss.Main$1.run(Main.java:508)
                          at java.lang.Thread.run(Thread.java:619)
                          Caused by: org.hibernate.MappingException: java.lang.ClassCastException: org.hibernate.reflection.java.JavaXFactory cannot be cast to org.hibernate.annotations.common.reflection.ReflectionManager
                          at org.jboss.envers.configuration.VersionsConfiguration.getReflectionManager(VersionsConfiguration.java:102)
                          at org.jboss.envers.configuration.VersionsConfiguration.configure(VersionsConfiguration.java:165)
                          at org.jboss.envers.configuration.VersionsConfiguration.getFor(VersionsConfiguration.java:251)
                          at org.jboss.envers.event.VersionsEventListener.initialize(VersionsEventListener.java:72)
                          at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:356)
                          at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1304)
                          at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
                          at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:713)
                          ... 145 more
                          Caused by: java.lang.ClassCastException: org.hibernate.reflection.java.JavaXFactory cannot be cast to org.hibernate.annotations.common.reflection.ReflectionManager
                          at org.jboss.envers.configuration.VersionsConfiguration.getReflectionManager(VersionsConfiguration.java:100)
                          ... 152 more

                          Please help.

                          Thanks a lot.

                          Louie Liu

                          • 10. Re: Regarding EnversHibernateToolTask
                            Adam Warski Master

                            Hello,

                            regarding the uni-directional one-to-many relations: these are not supported yet. They, and many-to-many relations are a bit more tricky as they involve an additional table in the DB. But I thought that they aren't used often :). Can you make the relation bi-directional or does it break something?

                            Adam

                            • 11. Re: Regarding EnversHibernateToolTask
                              Adam Warski Master

                              Hello,

                              regarding the second bug - what version of Hibernate/Hibernate EntityManager/Hibernate Annotations are you using? I don't even have the org.hibernate.reflection package.

                              I use 3.2.6/3.3.1/3.3.0.

                              Adam

                              • 12. Re: Regarding EnversHibernateToolTask
                                Anthony Whitford Newbie

                                Note that unidirectional relationships occur all of the time. Imagine a reference entity like Country. Many tables will have a foreign key contraint to Country, but Country is not linked to every table that references it (at least at the Java layer).

                                • 13. Re: Regarding EnversHibernateToolTask
                                  Adam Warski Master

                                  Hello,

                                  what I wrote was wrong: unidirectional many-to-one relations are supported, but only from one end - the owning one. So in the cases where you don't need an additional table to store the relation. In other words, if you have a @OneToMany collection-valued field, it always must have the "mappedBy" attribute set.

                                  Sorry for the confusion :)

                                  Adam

                                  • 14. Re: Regarding EnversHibernateToolTask
                                    Louie Liu Newbie

                                    Ok, my questions is that what to happen if there is no relationship defined on the one-to-many side, only many-to-one defined with additional hibernate forengnKey constrain annotation. For example, for employee entity, we have this relationship defined:

                                    @ManyToOne(fetch = FetchType.EAGER)
                                    @ForeignKey(name = "FK_department")
                                    private Department department;

                                    and there is no one-to-many defined on the department side.

                                    I wonder if your software support this kind of relationship.

                                    Thanks a lot.

                                    Louie



                                    1 2 Previous Next