xml里有的property,在class里必须有对应的field(其实是getter、setter)。
class里有的field,在xml里可以没有。
用composite primary keys
http://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/#d0e2177
@Entity
public class Parent implements Serializable {
@Id
public ParentPk id;
...
}
@Embeddable
public class ParentPk implements Serializable {
String firstName;
String lastName;
...
}
从没接触过无主键表操作。
可以无主键的,无主键就是所有的列联合成为一个主键,映射后会多出一个Java文件是表名id.java文件,意思是封装过了的表存入id那个类中
用hibernate开发要注意数据库中的每张表都应该有一个主键的。