Hibernate - Jboss Forge add a null element in my list ManyToMany

140 Views Asked by At

I generate simple CRUD with Jboss forge. It's ok but when i get the list of my Entity (postesPrejudices) , a null element is added :

My entity :

@ManyToMany
@JoinTable(name = "COR_TYPEFICHE_REGRPRJ", 
        joinColumns = {@JoinColumn(name = "ID_TYPEFICHE", referencedColumnName = "ID")}, 
        inverseJoinColumns = @JoinColumn(name = "ID_REGRPRJ", referencedColumnName = "ID"))
@OrderColumn(name = "ORDRE")
private List<RegroupementPostePrejudice> postesPrejudices;

Here is my view, I use classic View with unit persist:

@Named
@Stateful
@ConversationScoped
public class TypeFicheBean implements Serializable {
...

    @Inject
    private Conversation conversation;

    @PersistenceContext(unitName = "persistence-unit", type = PersistenceContextType.EXTENDED)
    private EntityManager entityManager;

    public void retrieve() {

        if (FacesContext.getCurrentInstance().isPostback()) {
            return;
        }

        if (this.conversation.isTransient()) {
            this.conversation.begin();
            this.conversation.setTimeout(1800000L);
        }

        if (this.id == null) {
            this.typeFiche = this.example;
        } else {

            this.typeFiche = findById(getId());

        }
    }

public TypeFiche findById(Long id) {
        return this.entityManager.find(TypeFiche.class, id);
    }
0

There are 0 best solutions below