Vatsal Prakash
Vatsal Prakash

Reputation: 558

Java- JPA @Entity and @Embeddable together

I'm new to Spring jpa and have a usecase where I need to create:

Table A : With Columns 'a' , 'b' and 'c'

And Table B : With Columns 'd' and also columns which are there in Table A .

My question is ,

Can I annotate the POJO for Table A both with @Entity and @Embeddable ?

Upvotes: 1

Views: 189

Answers (1)

dipak patil
dipak patil

Reputation: 46

You will have to put two annotation by name @Embeddable and @MappedSuperclass on above the table A entity and also you will have to inherit table A entity into the table B entity like below.

@Embeddable
@MappedSuperclass
@Entity
class TableA{....}

@Entity
Class TableB extends TableA{...}

Upvotes: 1

Related Questions