문제

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

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

Thanks

도움이 되었습니까?

해결책

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top