Hibernate映射异常 - 无法确定类型: [英] Hibernate mapping exception - Could not determine type for:

查看:121
本文介绍了Hibernate映射异常 - 无法确定类型:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  org.hibernate.MappingException:无法确定类型对于:com.sd.entity.SDUserProductAcess,在表中:SDUser,用于列:[org.hibernate.mapping.Column(productAccess)] 
[PersistEngine]无法初始化持久性引擎!java.lang.NullPointerException

这些是我的实体:

  @Entity 
@Inheritance(strategy = InheritanceType.JOINED)
public class SDObject
{

@Id
@GeneratedValue
私人长期sdId;
private String sdType;

public long getSdId()
{
return sdId;
}

public void setSdId(long sdId)
{
this.sdId = sdId;
}

public String getSdType()
{
return sdType;
}

public void setSdType(String sdType)
{
this.sdType = sdType;


$ / code>

下一个:

  @Entity 
public class SDUser extends SDObject
{

@Column(unique = true)
私人字符串代码;
私人字符串密码;
private SDUserProductAcess productAccess;

public String getCode()
{
return code;
}

public void setCode(String code)
{
this.code = code;
}

public String getPassword()
{
return password;
}

public void setPassword(String password)
{
this.password = password;
}

@OneToMany(cascade = CascadeType.ALL,fetch = FetchType.LAZY)
public SDUserProductAcess getProductAccess()
{
return productAccess;
}

public void setProductAccess(SDUserProductAcess productAccess)
{
this.productAccess = productAccess;
}

最后一个:

  @Entity 
public class SDUserProductAcess extends SDObject
{

private boolean adm;

public boolean isAdm()
{
return adm;
}

public void setAdm(boolean adm)
{
this.adm = adm;


Hibernate无法确定列productAccess的类型,位于SDUser实体中。
我是Hibernate的新手,我无法弄清楚发生了什么。



我应该提供某种ID吗?



谢谢!!

解决方案

SDUser 您需要在 SDUserAccess 中添加关联信息:

  @ManyToOne 
@JoinColumn(name =sdId)
private SDUserProductAcess productAccess;


Im trying to configure my entities but hibernate throws the following exception:

org.hibernate.MappingException: Could not determine type for: com.sd.entity.SDUserProductAcess,   at table: SDUser, for columns: [org.hibernate.mapping.Column(productAccess)]
[PersistEngine] Failed to initialize persistence engine!java.lang.NullPointerException

These are my Entities:

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class SDObject
{

@Id
@GeneratedValue
private long sdId;
private String sdType;

public long getSdId()
{
    return sdId;
}

public void setSdId(long sdId)
{
    this.sdId = sdId;
}

public String getSdType()
{
    return sdType;
}

public void setSdType(String sdType)
{
    this.sdType = sdType;
}
}

The next one:

@Entity
public class SDUser extends SDObject
{

@Column(unique = true)
private String code;
private String password;
private SDUserProductAcess productAccess;

public String getCode()
{
    return code;
}

public void setCode(String code)
{
    this.code = code;
}

public String getPassword()
{
    return password;
}

public void setPassword(String password)
{
    this.password = password;
}

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
public SDUserProductAcess getProductAccess()
{
    return productAccess;
}

public void setProductAccess(SDUserProductAcess productAccess)
{
    this.productAccess = productAccess;
}

The last one:

@Entity
public class SDUserProductAcess extends SDObject
{

private boolean adm;

public boolean isAdm()
{
    return adm;
}

public void setAdm(boolean adm)
{
    this.adm = adm;
}
}

Hibernate can't determine the type for column productAccess, located in SDUser entity. I'm new to Hibernate and I can't figure out what is happening.

Should I provide some kind of ID?

Thanks!!

解决方案

In SDUser you need to add the association info on the SDUserAccess:

@ManyToOne
@JoinColumn(name = "sdId")
private SDUserProductAcess productAccess;

这篇关于Hibernate映射异常 - 无法确定类型:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆