Configure orphanRemoval = true in Generate Entities of Table - JPA Tools - Eclipse

0

I'm having a problem every time I need to use the Generate Entities of Table from JPA Tools (use Eclipse Neon.3). I generate the entities with the Generate Entities of Table command from JPA Tools. In the code of a class in the annotation of a relationship I add the code orphanRemoval=true and saved everything right. When I need to use the Generate Entities of Table command again, when I look at the same class I entered, the orphanRemoval=true no longer exists.

How do I configure JPATools (Generate Custom Entities screens) to insert orphanRemoval = true in a relationship so that it is stored and every time I need to use the command to generate the table entities automatically enter orphanRemoval? Just like you select cascade on the Generate Custom Entities screen and it keeps memorized.

See the code snippet below:

When you generate the entity with JPA Tools:

@OneToMany(mappedBy="pessoa", cascade={CascadeType.ALL})
    private Set<PessoaContato> listaPessoaContato;

Manually enter orphanRemoval in the code and save:

@OneToMany(mappedBy="pessoa", cascade={CascadeType.ALL},orphanRemoval=true)
    private Set<PessoaContato> listaPessoaContato;

When I need to regenerate again, jpa tools overwrites all classes by deleting everything that is manually entered, so the code snippet returns:

@OneToMany(mappedBy="pessoa", cascade={CascadeType.ALL})
    private Set<PessoaContato> listaPessoaContato;
    
asked by anonymous 01.10.2017 / 05:16

1 answer

1

The only direct reference on such an option that I found is many years ago and basically it was said that it was not supported and there were no plans for it.

The reason, I believe, is that the table-based entity generation tool is an initial help and does not pretend to automate the evolution of classes by regenerating them at every change in the database.

I did a search to see if there was a way to bind this option by default or overwrite the annotation externally, regardless of field annotation, but found no results.

The best solution would be to use the tool only to generate only the classes referring to the new tables, without overwriting the existing ones.

An alternative would be to create a tool to process the generated classes and add information where convenient automatically.

    
10.10.2017 / 23:13