If we have
@Entity
@IdClass(DependentId.class)
public class Dependent
{
@Id String name;
@Id
@ManyToOne
Employee employee;
}
@Entity
public class Employee
{
@Id
long id;
}
then we ideally want to define DependentId as
public class DependentId
{
String name; // matches name of @Id attribute
long employee; // matches name of @Id attribute and type of Employee PK
...
}
but currently we require that "employee" is of type org.datanucleus.identity.LongId
dnCopyKeyFieldsToObjectId would need changing to do
Field field = o.getClass().getDeclaredField("name");
field.setAccessible(true);
field.set(o, this.name);
instead of
o.employee = ((LongId)this.employee.dnGetObjectId());
dnCopyKeyFieldsFromObjectId would need changing to do
Object id = new LongId(Employee.class, o.employee);
fc.storeObjectField(0, dnGetExecutionContext().findObject(id, false));
instead of
fc.storeObjectField(0, dnGetExecutionContext().findObject(o.employee, false));
One downside of this possible change is that the current o.employee stored as LongId also contains the class that is being represented, whereas using just a long loses that
If we have
then we ideally want to define
DependentIdasbut currently we require that "employee" is of type
org.datanucleus.identity.LongIddnCopyKeyFieldsToObjectId would need changing to do
instead of
dnCopyKeyFieldsFromObjectId would need changing to do
instead of
One downside of this possible change is that the current o.employee stored as
LongIdalso contains the class that is being represented, whereas using just a long loses that