Note that there are some explanatory texts on larger screens.

plurals
  1. PODo persistent class properties forming composite key also need to be serializable or transient in case of non-serializable?
    primarykey
    data
    text
    <p>I have a persistent class : </p> <pre><code>public class NotifEventGroupRel implements Serializable{ private static final long serialVersionUID = 7616645672995663305L; private Long eventGroupId; private String eventName; private NotifEventGroup notifEventGroup; //// composite id property private EmailTmplt emailTmplt; // composite id property private SmsTmplt smsTmplt; // composite id property .... } </code></pre> <p>Its hbm.xml file is :</p> <pre><code>&lt;hibernate-mapping&gt; &lt;class name="NotifEventGroupRel" table="TBLMEVENTGROUPREL"&gt; &lt;composite-id&gt; &lt;key-many-to-one name="notifEventGroup" class="NotifEventGroup" lazy="false" &gt; &lt;column name="EVENTGROUPID" precision="20" scale="0" not-null="true" /&gt; &lt;/key-many-to-one&gt; &lt;key-property name="eventName" type="java.lang.String"&gt; &lt;column name="EVENT" /&gt; &lt;/key-property&gt; &lt;/composite-id&gt; &lt;many-to-one name="emailTmplt" class="EmailTmplt" lazy="false" not-null="false" &gt; &lt;column name="EMAILTMPLTID"&gt;&lt;/column&gt; &lt;/many-to-one&gt; &lt;many-to-one name="smsTmplt" class="SmsTmplt" lazy="false" not-null="false"&gt; &lt;column name="SMSTMPLTID" /&gt; &lt;/many-to-one&gt; &lt;/class&gt; &lt;/hibernate-mapping&gt; </code></pre> <p>The class of properties forming composite id is :</p> <pre><code>public class NotifEventGroup { private Long eventGroupId; private String name; ....... } public class EmailTmplt { private Long emailTmpltId; private String name; ..... } public class SmsTmplt { private Long smsTmpltId; private String name; .......... } </code></pre> <ul> <li>Do i need to make following properties transient :</li> </ul> <p>(shown below)</p> <pre><code>private transient NotifEventGroup notifEventGroup; //// composite id property private transient EmailTmplt emailTmplt; // composite id property private transient SmsTmplt smsTmplt; // composite id property </code></pre> <p>because findbug gives me <strong><code>Non-transient non-serializable instance field in serializable class</code></strong> error for the fields (if non transient).</p> <ul> <li>OR do i have to make their corresponding class serializable ?</li> </ul> <p>And what is the impact of doing any of the above two cases ?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload