[infinispan-issues] [JBoss JIRA] (ISPN-9443) Fail when single region is accessed with multiple strategies

Diego Lovison (JIRA) issues at jboss.org
Wed Aug 22 07:37:00 EDT 2018


    [ https://issues.jboss.org/browse/ISPN-9443?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13622566#comment-13622566 ] 

Diego Lovison edited comment on ISPN-9443 at 8/22/18 7:36 AM:
--------------------------------------------------------------

If this is the case, then we have a different issue.
The following example is working:

{code:java}

         AtomicLong p1Id = new AtomicLong(0L);

         doWork(factory, (session) -> {
            Person p1 = new Person("p-name", "p-code", Arrays.asList(new Phone("pp-1"), new Phone("pp-2")));
            session.persist(p1);
            p1Id.set(p1.getId());
         });

         doWork(factory, (session) -> {
            session.find(Person.class, p1Id.get()).getPhones().add(new Phone("pp-3"));
         });
         
         doWork(factory, (session) -> {
            Assert.assertEquals(3, session.find(Person.class, p1Id.get()).getPhones().size());
         });
{code}

SQL:
{noformat}
Hibernate: insert into phone (mobile, id) values (?, ?)
Hibernate: update person set name=?, version=? where id=? and version=?
Hibernate: delete from person_phone where Person_id=?
Hibernate: insert into person_phone (Person_id, phones_id) values (?, ?)
Hibernate: insert into person_phone (Person_id, phones_id) values (?, ?)
Hibernate: insert into person_phone (Person_id, phones_id) values (?, ?)
{noformat}


was (Author: dlovison):
If this is the case, then we have a different issue.
The following example is working:

{code:java}

         AtomicLong p1Id = new AtomicLong(0L);

         doWork(factory, (session) -> {
            Person p1 = new Person("p-name", "p-code", Arrays.asList(new Phone("pp-1"), new Phone("pp-2")));
            session.persist(p1);
            p1Id.set(p1.getId());
         });

         doWork(factory, (session) -> {
            session.find(Person.class, p1Id.get()).getPhones().add(new Phone("pp-3"));
         });
         
         doWork(factory, (session) -> {
            Assert.assertEquals(3, session.find(Person.class, p1Id.get()).getPhones().size());
         });
{code}


> Fail when single region is accessed with multiple strategies
> ------------------------------------------------------------
>
>                 Key: ISPN-9443
>                 URL: https://issues.jboss.org/browse/ISPN-9443
>             Project: Infinispan
>          Issue Type: Enhancement
>          Components: Hibernate Cache
>    Affects Versions: 9.3.1.Final
>            Reporter: Radim Vansa
>             Fix For: 9.4.0.Final
>
>
> When we have two entities that share the same region but use different access strategies the Hibernate boot should fail. Right now there's an assertion in {{DomainDataRegionImpl.prepareFor*}} but this does not give much explanation and does not fail when assertions are disabled which leads to cryptic errors later on.
> Example:
> {code}
> @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, region = "item")
> public static class NonStrictReadWriteVersionedCacheableItem { ... }
> @Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "item")
> public static class ReadWriteVersionedCacheableItem { ... }
> {code}



--
This message was sent by Atlassian JIRA
(v7.5.0#75005)


More information about the infinispan-issues mailing list