Aviskar Basnet
Aviskar Basnet

Reputation: 23

Hibernate - Does hibernate use proxy objects if there is no associations?

There is no association in the entity shown below.
Does hibernate use proxy object to retrieve the User object?
The question is little bit same as this one.
But what if there is no associations?

@Entity
@Table(name="user")
public class User {
    @Id
    @GeneratedValue
    private int id;
    private String name;

    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
}

Upvotes: 1

Views: 60

Answers (1)

v.ladynev
v.ladynev

Reputation: 19956

Use this to test for proxy

boolean proxy = user instanceof HibernateProxy;

Upvotes: 1

Related Questions