Skip to content

NH-2241 - IStatelessSession is accidentally 2LC enabled in some cases #652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 24, 2017

Conversation

igitur
Copy link
Contributor

@igitur igitur commented Jun 22, 2017

NH-2241 - When inserting an entity that references an entity with assigned id causes exception if that entity as a cache property.

Example:

<class name="Document" >
    <cache region="ShortTerm" usage="read-write" />
    <id name="Name" >
        <generator class="assigned"/>
    </id>
    <property name="Text"/>
</class>
<class name="Paper">
    <id name="Id">
        <generator class="native"/>
    </id>
    <property name="Color"/>
    <many-to-one name="Document" column="DocId" cascade="none" />
</class>

When inserting a Paper entity using BatchInsert in the stateless session throws NotSupported exception from the Timestamp property on the session (ISessionImplementor).

This happens in the end of the IsTransient method (of the AbstractEntityPersister):

// check to see if it is in the second-level cache
if (HasCache)
{
    CacheKey ck = new CacheKey(id, IdentifierType, RootEntityName, session.EntityMode, session.Factory);
    if (Cache.Get(ck, session.Timestamp) != null)
        return false;
}

Also logged at https://nhibernate.jira.com/browse/NH-2241

This PR adds a unit test, but unfortunately I couldn't find a solution for this bug.

@igitur igitur changed the title Batch insert using stateless session NH-2241 Batch insert using stateless session Jun 22, 2017
@igitur igitur changed the title NH-2241 Batch insert using stateless session NH-2241 - Batch insert using stateless session Jun 22, 2017
@hazzik hazzik force-pushed the batch-insert-using-stateless-session branch from 275d2da to ae85e80 Compare June 23, 2017 12:38
hazzik
hazzik previously approved these changes Jun 23, 2017
@hazzik hazzik force-pushed the batch-insert-using-stateless-session branch from ae85e80 to 71c354f Compare June 23, 2017 12:42
@hazzik hazzik changed the title NH-2241 - Batch insert using stateless session NH-2241 - IStatelessSession is accidentally 2LC enabled in some cases Jun 24, 2017
@hazzik hazzik merged commit a4cbae9 into nhibernate:master Jun 24, 2017
@igitur
Copy link
Contributor Author

igitur commented Jun 26, 2017

Thank you for the quick fix. Much appreciated.

@igitur igitur deleted the batch-insert-using-stateless-session branch June 26, 2017 09:06
@fredericDelaporte fredericDelaporte added this to the 5.0.0 milestone Jun 26, 2017
@hazzik hazzik added the r: Fixed label Aug 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants