JBoss Community

Re: How to add constructors with ID in pojo generation?

created by u j in JBoss Tools - View the full discussion

What is an assigned id?

 

Maybe I am going the wrong way, but I explain what I try to do: I persist an new entity which has a child entity (many-to-one relationship). The entity has a foreign key of the child, but the child is not updated and already exists. The entity class has a field of type child entity.

So I want to set the foreign key easily by

entity.setChild(new ChildEntity(childId))

instead of

ChildEntity c = new ChildEntity();

c.setId(childId);

entity.setChild(c);

 

3 lines instead of 1!

I don't need to set the other fields of the child entity as it is not persisted.

 

Thanks

Reply to this message by going to Community

Start a new discussion in JBoss Tools at Community