Issue Type: Bug Bug
Affects Versions: 4.1.7, 4.1.6
Assignee: Unassigned
Components: caching (L2), query-criteria
Created: 26/Sep/12 10:57 PM
Description:

When annotating a class with @NaturalIdCache and using bySimpleNaturalId() I get a NPE.
This is a snippet of the entity class:

Page.java
@Entity
@Table(name = "Page")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@NaturalIdCache
public class Page {
	
	private long id;
	private String url;
	private String name;
	private String title;
	private String image;
	private String description;
	private Page parent;
	private List<Page> children;
	private boolean visible;
	private boolean internal;
	private boolean file;
	private int orden;

	@Id
	@NotNull
	@Column(name = "id")
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}
	
	@NaturalId
	@NotNull
	@Column(name = "name")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
}

This query throws a NPE.

bySimpleNaturalId() query
Page result = (Page) getSession().bySimpleNaturalId(Page.class).load(pageName);

This is the workaround criteria based-query, works perfectly

criteria based query
Page result = (Page) getSession().createCriteria(Page.class).add(Restrictions.naturalId().set("name", pageName)).setCacheable(true).uniqueResult();
Environment: Hibernate 4.1.7.Final, MySQL 5.5.22, Spring 3.1.2.RELEASE, ehCache 2.6.0
Project: Hibernate ORM
Priority: Minor Minor
Reporter: Francisco Pérez
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira