1 Reply Latest reply on Jul 2, 2008 3:11 AM by Adam Warski

    Enver does not support the unidirectional @OneToMany associa

    Louie Liu Newbie

      We would like to request a new feature in Envers to support the unidirectional @OneToMany association. Here is the user case:

      @Entity
      @Versioned
      public class Entity1 {
      
       @Id
       private int id;
       private String name;
      
      }
      
      @Entity
      @Versioned
      public class Entity2 {
      
       @Id
       private int id;
       private String name;
      
       @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
       @JoinColumn(name="calendar")
       private Set<Entity1> entity1;
      
      }
      


      Currently, it is failed with the following error message:

      
      [hibernatetool] org.hibernate.MappingException: Unable to read the mapped by attribute for holidays
      [INFO] ------------------------------------------------------------------------
      [ERROR] BUILD ERROR
      [INFO] ------------------------------------------------------------------------
      [INFO] Error executing ant tasks
      
      Embedded error: org.hibernate.MappingException: Unable to read the mapped by attribute for holidays
      [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: Unable to read the mapped by attribute for holidays
       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: Unable to read the mapped by attribute for holidays
       at org.jboss.envers.metadata.VersionsMetadataGenerator.addOneToMany(VersionsMetadataGenerato
      r.java:286)
       at org.jboss.envers.metadata.VersionsMetadataGenerator.addProperties(VersionsMetadataGenerat
      or.java:395)
       at org.jboss.envers.metadata.VersionsMetadataGenerator.generateSecondPass(VersionsMetadataGe
      nerator.java:554)
       at org.jboss.envers.configuration.VersionsConfiguration.configure(VersionsConfiguration.java
      :211)
       at org.jboss.envers.configuration.VersionsConfiguration.getFor(VersionsConfiguration.java:27
      4)
       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
      
      


      Also, it should support List, Set and Map data type for associated attribute. Thanks.

      Louie