here is a snippet of my entity (it also has hashcode and equals created which are the default ones generated by java
@Entity
@Table(name = "media_tspec_external_registry")
public class Registry implements Serializable {
public Registry() {
//for hibernate :D
}
public Registry(String show, String protocol, String externalEndpoint, String userURI, String version) {
super();
this.show = show;
this.protocol = protocol;
this.externalEndpoint = externalEndpoint;
this.userURI = userURI;
this.version = version;
}
@Id
@Column(name = "show", nullable = false)
private String show;
@Id
@Column(name = "protocol", nullable = false)
private String protocol;
@Column(name = "external_endpoint", nullable = true)
private String externalEndpoint;
here is my method which is trying to load an entity which does not exist, based on these key values
Registry reg = new Registry("invalid", "idvalue", null, null, null);
Registry reg2 = null;
try {
reg2 = (Registry) session.load(Registry.class, reg);
} catch (HibernateException e) {
throw new UserException("A registry entry does not exist for this show: " + show + " and protocol: " + protocol);
}
it never throws the exception and reg2 is now set to a registry object with all the fields set to null.
i have also noted that the load will not even load a existing entity.
however if i use get instead it works as expected (loading valid object returning null for non existing objects)
reg2 = (Registry) session.get(Registry.class, reg);
any explanation would be appreciated.
Thanks