Question

I am using hbm2java (hibernate3-maven-plugin) in order to generate entities.

How do I switch the auto generated @EmbeddedId to @IdClass?

Thanks

Was it helpful?

Solution

The hibernate maven plugin doesn't do that automatically, you need to update your classes manually if you want to use @IdClass.

OTHER TIPS

I have not tried to following. But from what I have been working with Hibernate reverseengineering tool I think it should be possible by using a reveng.xml file. In your pom file.

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>hibernate3-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
    <components>
        <component>
            <name>hbm2java</name>
        </component>
    </components>
    <componentProperties>
       <revengfile>/src/main/resources/reveng/model.reveng.xml</revengfile>
    </componentProperties>
    </configuration>
    <executions>
  <execution>
  <phase>compile</phase>
  <goals>
    <goal>hbm2java</goal>
  </goals>
  </execution>
</executions>

And in the reveng.xml specify the type mapping to the IdClass (see Hibernate tools documentation http://docs.jboss.org/tools/3.1.0.GA/en/hibernatetools/html_single/index.html#type_map or http://docs.jboss.org/tools/3.1.0.GA/en/hibernatetools/html_single/index.html#d0e5869).

As mentioned, I have not tried it.

For various other reason I gave up on using reverse engineering. One problem is that hibernate tools is not compliant with Hibernate 3.5 and above. Furthermore the Maven plugin is third party and uses an older versions of Hibernate tools, than the one general available. So I also came into the situation where I had to call ant from Maven to do the reverse engineering.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top