I am using java codeModel to generate hibernate entity classes.
Where tables have compound keys, i am generating an @Embeddable
class that i then need to define a field for in my entity class.
currently this compound key class is being defined as a fully qualified name with no java import statement in my entity class: e.g
private com.aaa.bbb.CompoundKey compoundKey;
How do i tell codeModel NOT to fully qualify my CompoundKey field? e.g
import com.aaa.bbb.CompoundKey;
private CompoundKey compoundKey;
I create my entity class like this
JCodeModel codeModel = new JCodeModel();
JDefinedClass entityClass = codeModel._class("com.aaa.bbb.EntityClassName");
i create my compound key class like this
JDefinedClass compoundKeyClass = codeModel._class("com.aaa.bbb.CompoundKeyClassName");
i create the compoundKey field in the entity class like this
JFieldVar field = entityClass.field(JMod.PRIVATE, compoundKeyClass, "compoundKey");