它实现了如下所示的模型:
我实现了三类模型:
@Entity
public class Home implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@OneToMany(mappedBy = "home")
private Set<UserHome> userHomes;
}
@Entity
public class UserHome implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ManyToOne
@JoinColumn(name = "home_id")
private Home home;
@OneToMany(mappedBy = "userhome")
private Set<Key> keys;
}
@Entity
public class Key implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ManyToOne
@JoinColumn(name = "userhome_id")
private UserHome userHome;
}
当您尝试编译时会出现错误:
调用init方法失败;嵌套异常是org.hibernate.AnnotationException:mappedBy引用一个未知的目标实体属性:com.example.homeUser.UserHome.keys中的com.example.homeUser.Key.userhome
我不知道我的代码有什么问题?
答案 0 :(得分:1)
您的代码中存在拼写错误,$mimetype = mime_content_type($path);
switch ($mimetype) {
case "video/mp4":
// what is currently your case "1"
break;
case "image/jpeg":
case "image/pjpeg":
case "image/png":
case "image/gif":
// what is currently your case "2"
break;
default:
return array(
0,
"file format is unknown"
);
}
中的小写h:
userhome
应为(大写H):
@OneToMany(mappedBy = "userhome")
private Set<Key> keys;
您在@OneToMany(mappedBy = "userHome")
private Set<Key> keys;
这样的字段中引用的字段/属性应该具有JavaBean中字段的确切名称和大小写。