Hi,
I'm using Hibernate 4.0.1. I have a class User mapped to my USERS table. A sample of the fields are below ...
Code:
@Entity
@Table(name = "USERS")
public final class Registration implements UserDetails, Serializable {
@Id
@Column(name = "ID")
@GeneratedValue(strategy=GenerationType.AUTO)
private Integer id;
@NotEmpty
@Column(name = "USERNAME")
private String username;
@NotEmpty
@Size(min = 4)
@Column(name = "PASSWORD")
private String password;
@Transient
private String confirmPassword;
@NotEmpty
@Email
@Column(name = "EMAIL")
private String email;
@Column(name = "FIRST_NAME")
private String firstName;
@Column(name = "LAST_NAME")
private String lastName;
@OneToMany(fetch = FetchType.EAGER, targetEntity = EventFeed.class)
@JoinTable(name = "USER_EVENT_FEEDS", joinColumns = { @JoinColumn(name = "USER_ID") }, inverseJoinColumns = { @JoinColumn(name = "EVENT_FEED_ID") })
private Set<EventFeed> userEventFeeds = new HashSet<EventFeed>(0);
@OneToMany(fetch = FetchType.EAGER, targetEntity = Role.class)
@JoinTable(name = "USER_ROLES", joinColumns = { @JoinColumn(name = "USER_ID") }, inverseJoinColumns = { @JoinColumn(name = "ROLE_ID") })
private Set<Role> userRoles = new HashSet<Role>(0);
How would I do a search on the non-null fields of a User object? In other words, if the User object only contained a non-null firstName field, I would want to do a search on all users with a matching first name.
Thanks, - Dave