我有两个具有以下结构的表
@hibernate.class table = "Person"
class Person{
private String name
private Car car
@hibernate.id column = "NAME" generator-class = "native"
@hibernate.generator-param name = "sequence" value = "SEQ_1"
public String getName(){return name;}
public void setName(String name){this.name=name;}
@hibernate.many-to-one column="MODEL_ID" class="CAR" cascade="all"
public Car getCar(){return car;}
public void setCar(Car car){this.car=car;}
}
@hibernate.class table = "CAR"
class Car{
private String modelID;
private String carName;
@hibernate.id column = "MODEL_ID" generator-class = "assigned"
public String getModelID(){return modelID}
etc....
}
但是当我尝试删除或保存 Person 类时,它休眠会引发此异常
这是完整的异常代码: org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient instance - save the transient
你能给我任何帮助吗?