Announcement Announcement Module
Collapse
No announcement yet.
HQL query object collection's attribute Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • HQL query object collection's attribute

    I'm trying to query the collection "followees" in my Spitter class. But I'm not sure how to. And if there's a way, is it possible for each instance in the list to return an attribute instead of Followee object?

    Spitter:
    Code:
    @Entity
    @Table(name="SPITTER")
    public class Spitter implements Serializable {
    
        @Id
        @GeneratedValue
        @Column(name="ID")
        private int id;
    
        @Column(name="USERNAME")
        private String userName;
    
        @Column(name="PASSWORD")
        private String password;
    
        @Column(name="FULLNAME")
        private String fullName;
    
        @Column(name="EMAIL")
        private String email;
    
        @ElementCollection
        @CollectionTable(name = "FOLLOWEE", joinColumns = @JoinColumn(name = "SPITTER_ID"))
        private List<Followee> followees = Lists.newArrayList();
    
        @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
        @JoinColumn(name = "SPITTER_ID")
        private List<Spittle> spittles = Lists.newArrayList(); 
    
        //getters/setters/ hash/equals etc
    Followee:
    Code:
    @Embeddable
    public class Followee implements Serializable {
    
        @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
        @JoinColumn(name = "FOLLOWEE_ID", insertable = false, updatable = false)
        private Spitter spitter;
Working...
X