这是我的实体类:
@Entity
public class User implements Serializable {
@Column(name = "instagram_token")
private Token instagramToken;
@Column(name = "paypal_credential")
private SignatureCredential signatureCredential;
Token和SignatureCredential是第三方类。 Hibernates确定令牌的类型,但不能对SignatureCredential做同样的事情,我不明白为什么。
public class Token implements Serializable {
private static final long serialVersionUID = 715000866082812683L;
private final String rawResponse;
private final String secret;
private final String token;
public class SignatureCredential implements ICredential {
private String userName;
private String password;
private String applicationId;
private String signature;
private ThirdPartyAuthorization thirdPartyAuthorization;
public interface ThirdPartyAuthorization {
}
答案 0 :(得分:3)
您的令牌实体实现Serializable
,这是实体属性的有效类型。另一方面,SignatureCredential没有实现Serializable
,也没有Hibernate认可的任何类型都是有效的实体类型。除非,ICredential
接口扩展Serializable
接口(我在代码中没有看到)。
请参阅:https://docs.jboss.org/hibernate/orm/5.0/manual/en-US/html/ch05.html#mapping-types
在JPA中,这里是可以映射的有效简单类型: