Error with access="none" mapping

Description

Mapping a column in a class twice gives an error when building the envers configuration in ClassesAuditingData.UpdateCalculatedFields().

if (propertyAuditingData.ForceInsertable)
{
var referencedEntityName = MappingTools.ReferencedEntityName(pc.GetProperty(propertyName).Value);

// referencedEntityName is null with propertyName = ParentId -> exception when accessing the dictionary

var referencedClassAuditingData = entityNameToAuditingData[referencedEntityName];

forcePropertyInsertable(referencedClassAuditingData, propertyAuditingData.MappedBy,
pc.EntityName, referencedEntityName);

To reproduce:
Add the following to the Unit Test Object OneToMany/CollectionRefIngEntity.cs:

[Audited]
public virtual int? ReferenceId
{
get
{
if (Reference == null) return null;
return Reference.Id;
}
}

Update the Mapping.hbm.xml file for this class to:

<class name="CollectionRefIngEntity">
<id name="Id">
<generator class="assigned"/>
</id>
<property name="Data"/>
<property name="ReferenceId" column ="Reference" access="none" insert="0" update="0"/>
<many-to-one name="Reference" column ="Reference"
class="CollectionRefEdEntity" />
</class>

Environment

DB doesn't matter, it fails when creating the configuration

Activity

Show:

Roger January 7, 2016 at 11:15 PM

Peter Schojer January 7, 2016 at 4:27 PM

Hm,
This might be a fragment of my attempts to get it working somehow. I think
it also accurred without the property.
Br
Peter

Roger January 7, 2016 at 4:09 PM

In your example code above you have annotated ReferenceId property with [Audited]. Is this really correct? If the column doesn't even exists in db, it doesn't make sense to audit it - right?

(The issue is surely still there, just want the test to be correct).

Peter Schojer December 23, 2015 at 12:28 PM

I think access none is not enough to prevent insert/update statements being
generated for a column. I could be wrong though. It's pretty much my
standard mapping pattern

Roger December 23, 2015 at 11:57 AM

I started to look at this issue. Any particular reason you added insert=0 update=0 in the mapping (I know it doesn't work anyway - just want to setup the test "correct")?

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Who's Looking?

Open Who's Looking?

Created October 28, 2015 at 9:39 AM
Updated January 7, 2016 at 11:15 PM
Resolved January 7, 2016 at 11:15 PM
Who's Looking?