Does JPA support mapping to sql views?

前端 未结 3 716
野趣味
野趣味 2020-12-04 17:56

I\'m currently using Eclipselink, but I know now days most JPA implementations have been pretty standardized. Is there a native way to map a JPA entity to a view? I am not l

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-04 18:25

    In my view I have a "unique" id, so I mapped it as the Entity id. It works very well:

    @Entity
    @Table(name="table")
    @NamedQuery(name="Table.findAll", query="SELECT n FROM Table n")
    public class Table implements Serializable {
        private static final long serialVersionUID = 1L;
    
        @Id
        @Column(name="column_a")
        private int columnA;
    

提交回复
热议问题