How to make a join of tables and have all the attributes of each of them?

Suppose you have two objects, one Articleand the other Fruits. Now all attributes of the object Articleare inherited by the entity Fruits.

So let's say I have an article table with columns:

ART_ID
ART_NAME
ART_COST

and Fruit table with columns:

FRU_ID
FRU_FROZEN

Now I want to do it in my JPA-code that when retrieving the objects FruitI get all the data that must be them, the data consisting of information from my table Articleand Fruit ART_ID, ART_NAME, ART_COST, FRU_ID, FRU_FROZEN.

Is this possible in JPA? Should I use @Inheritance, @JoinColumnor what? If necessary, a code can be provided.


* EDIT *

I came to the conclusion that the code below will satisfy my needs:

@Entity
@Table(name = "Article")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Article {
    @Id @GeneratedValue(strategy=GenerationType.AUTO)
    @Basic(optional = false)
    @Column(name = "ART_ID")
    private Long id;

    @Basic(optional = false)
    @Column(name = "ART_NAME")
    private String name;

    @Basic(optional = true)
    @Column(name = "ART_COST")
    private String cost;  

    // ...
}

@Entity
@Table(name="Fruits")
@AttributeOverrides({
@AttributeOverride(name="name", column=@Column(name="ART_NAME")),
@AttributeOverride(name="cost", column=@Column(name="ART_COST")),
})
public class Fruits extends Article {

    @Id @GeneratedValue(strategy=GenerationType.AUTO)
    @Basic(optional = false)
    @Column(name = "FRU_ID")
    private Long fruitID;

    @Column(name="FRU_FROZEN")
    private String fruFrozen;

    //...
}

!

+3
1

Fruits Article s? () , @Inheritance .

Fruits, Hibernate - .

, Article ( ). @SecondaryTable , Hibernate.

+1

All Articles