Marco Janc edited a comment on Improvement HHH-7235

Thanks for that quick reply:

I simplified my code to a working example that produces same error.

Log: INFO: HHH000412: Hibernate Core {4.1.4.Final}

Mapping:

<hibernate-mapping>
    <class name="package.Node" table="node" catalog="database">
        <id name="id" type="java.lang.Integer">
            <column name="id" />
            <generator class="identity" />
        </id>
        <natural-id mutable="true">
	        <property name="name" type="string">
	            <column name="name" length="64" not-null="true" />
	        </property>
	        <many-to-one name="parent" class="package.Node" lazy="false" fetch="select" update="false">
	            <column name="parent" />
	        </many-to-one>
	</natural-id>
    </class>
</hibernate-mapping>

Check for duplicate existence using natural-id:

// check for existence
final NaturalIdLoadAccess nila = session.byNaturalId(Node.class);
nila.using("name", "test");
nila.using("parent", null);
Node node = (Node) nila.load(); // fires exception

if (node == null)
{
	node = new Node();
	node.setName("test");

	session.save(pc);
}
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