我正在尝试将实体放在不同的 Maven 项目中。在当前项目中,我有:
@Entity
public class User {
...
private FacebookUser facebookUser;
...
public FacebookUser getFacebookUser() {
return facebookUser;
}
...
public void setFacebookUser(FacebookUser facebookUser) {
this.facebookUser = facebookUser;
}
然后 FacebookUser (在不同的 Maven 项目中,这是当前项目的依赖项)定义为:
@Entity
public class FacebookUser {
...
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Long getId() {
return id;
}
这是我的 maven hibernate3-maven-plugin 配置:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>hbm2ddl</goal>
</goals>
</execution>
</executions>
<configuration>
<components>
<component>
<name>hbm2ddl</name>
<implementation>jpaconfiguration</implementation>
</component>
</components>
<componentProperties>
<ejb3>false</ejb3>
<persistenceunit>Default</persistenceunit>
<outputfilename>schema.ddl</outputfilename>
<drop>false</drop>
<create>true</create>
<export>false</export>
<format>true</format>
</componentProperties>
</configuration>
</plugin>
这是我得到的错误:
org.hibernate.MappingException: Could not determine type for: com.xxx.facebook.model.FacebookUser, at table: user, for columns: [org.hibernate.mapping.Column(facebook_user)]
我知道 FacebookUser 在类路径上,因为如果我让 facebook 用户瞬态,项目编译得很好:
@Transient
public FacebookUser getFacebookUser() {
return facebookUser;
}