Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Second level cache returns wrong value

Developers
Anonymous
2013-04-27
2013-05-14

  • Anonymous
    2013-04-27

    Hi,

    I have Two Table FOLDER and TOPIC. Their hbm as follows…

       _ <hibernate-mapping>
    <class name="com.company.Folder" table="FOLDER">
    <id name="folderId" type="java.lang.Long" >
    <column name="FOLDER_ID" />
    <generator class="native"/>
    </id>
    <many-to-one name="topicId"
    class="com.company.Topic" fetch="select" lazy="false" >
    <column name="TOPIC_ID" not-null="true" />
    </many-to-one>
    <property name="parentId" type="java.lang.Long">
    <column name="PARENT_ID" not-null="false" />
    </property>
    </class>
    </hibernate-mapping>

    <hibernate-mapping>
    <class name="com.company.Topic"
    table="TOPIC" >
    <cache usage="nonstrict-read-write"/>
    <id name="topicId" type="java.lang.Long">
    <column name="TOPIC_ID" precision="22" scale="0" />
    <generator class="native"/>

    </id>
    <property name="parentId" type="java.lang.Long">
    <column name="PARENT_ID" precision="22" scale="0"
    not-null="false" />
    </property>
    </class>
    </hibernate-mapping>_
    I have enabled second level ehcache for both table.

            <cache name="com.company.Folder"
        maxElementsInMemory="300" eternal="true" overflowToDisk="false"/>
        <cache name="com.company.Topic"
        maxElementsInMemory="300" eternal="true" overflowToDisk="false"/>

    when i call `folder.getTopicId().getParent()`  instand of hibernate returning parentId of TOPIC, it returns the parentId of FOLDER. Some time it returns correct value, but some time not.

    Can you help me to fix and explain this

    Thanks in advance