hasan
hasan

Reputation: 1104

Weak Entity Mapping in Hibernate

I have 2 classes:

@Entity
class A{
    @Id
    long id
    @???
    List<B> bs;
}

@????
class B{
    @ManyToOne
    A a;
    @OneToOne
    C c;
    Integer a,b,c,d,e;
}

how can i make hibernate to handle it ?? i dont want to put id on class B as it's a weak entity?

Upvotes: 0

Views: 1686

Answers (1)

Stanislav Bashkyrtsev
Stanislav Bashkyrtsev

Reputation: 15318

What do you mean by 'weak' entity? It just doesn't have an ID? Use

@ElementCollection
List<B> bs;

Along with

@Embeddable
class B {}

Find an example for instance here

Upvotes: 2

Related Questions