Problem in table name during hibernate creation

0

I am "annotating" an entity Menu using hibernate / jpa, and Menu contains a ShareActivity

asked by anonymous 10.01.2018 / 12:48

1 answer

0

Use the @AssociationOverride annotation. Example:

Class Menu :

@Entity
public class Menu { 

    @Embedded
    @AssociationOverride(name="status",joinTable=@JoinTable(name="menu_share_activity"))
    private ShareActivity enable;

    //outros métodos e atributos 
}

Class ShareActivity :

@Embeddable
public class ShareActivity {

    @ElementCollection
    @MapKeyColumn(name="actor")
    @MapKeyEnumerated(EnumType.STRING)
    @Column(name="value")
    private Map<Actor, Boolean> status;

    public ShareActivity() {
        this.status = new HashMap<Actor, Boolean>();
        this.status.put(Actor.owner, true);
        this.status.put(Actor.company, false);
        this.status.put(Actor.custumers, false);
        this.status.put(Actor.employee, false);
        this.status.put(Actor.friend, false);
    }
}
    
10.01.2018 / 14:35