Questions Tagged With persistencehttps://answers.axonivy.com/tags/persistence/?type=rss&user=HaraldWeberquestions tagged <span class="tag">persistence</span>enThu, 14 Aug 2014 11:32:10 -0400Why can I only have one field of the type List in my entity class?https://answers.axonivy.com/questions/912/why-can-i-only-have-one-field-of-the-type-list-in-my-entity-class<p>When I create a new entity class and want to have more than one List in it, Xpert.ivy says: "If an entity class has more than one collection you have to use 'Set' instead of 'List' as type."</p> <p>I think the JEE Persistence API does not have this limitation.</p>HaraldWeberThu, 14 Aug 2014 11:32:10 -0400https://answers.axonivy.com/questions/912/why-can-i-only-have-one-field-of-the-type-list-in-my-entity-classpersistencePersistence Api - Many to Many Relationshiphttps://answers.axonivy.com/questions/616/persistence-api-many-to-many-relationship<p>Is it possible to declare a many to many relationship in the Entity Class Editor?</p>HaraldWeberWed, 02 Apr 2014 14:12:20 -0400https://answers.axonivy.com/questions/616/persistence-api-many-to-many-relationshippersistencePersistence Api - Foreign Key is always nullhttps://answers.axonivy.com/questions/588/persistence-api-foreign-key-is-always-null<p>Hi</p> <p>currently i'm trying to use the persistence api. I stuck at inserting a one to many relationship. The problem is that the foreign key is always null.</p> <p>I have two entity classes. User and Option.</p> <h3>User</h3> <table border="1"> <tbody><tr> <th>Name</th> <th>Type</th> <th>DB Field</th> <th>Persistent</th> <th>Length</th> <th>Properties</th> <th>Association</th> <th>Cascade</th> <th>Mapped by</th> </tr> <tr> <td>id</td> <td>Integer</td> <td>id</td> <td>yes</td> <td></td> <td>id, generated</td> <td></td> <td></td> <td></td> </tr> <tr> <td>name</td> <td>String</td> <td>name</td> <td>yes</td> <td>255</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>opts</td> <td>Listy&lt;Option&gt;</td> <td></td> <td>yes</td> <td></td> <td></td> <td>ONE_TO_MANY</td> <td>persist, merge</td> <td>user_fk</td> </tr> </tbody></table> <h3>Option</h3> <table border="1"> <tbody><tr> <th>Name</th> <th>Type</th> <th>DB Field</th> <th>Persistent</th> <th>Length</th> <th>Properties</th> <th>Association</th> <th>Cascade</th> <th>Mapped by</th> </tr> <tr> <td>id</td> <td>Integer</td> <td>id</td> <td>yes</td> <td></td> <td>id, generated</td> <td></td> <td></td> <td></td> </tr> <tr> <td>option</td> <td>String</td> <td>opt_value</td> <td>yes</td> <td>255</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>user_fk</td> <td>User</td> <td>user_fk</td> <td>yes</td> <td></td> <td>not nullable</td> <td>MANY_TO_ONE</td> <td>persist, merge</td> <td></td> </tr> </tbody></table> <p>The Option Objects are created from strings by a converter from a p:selectManyCheckbox. The field user_fk is not set manually in this converter because i don't have a reference to the User object in the converter.</p> <p>Xpert.ivy creates an entity class for User and adds a "setOpts(List)" method for me.</p> <p><code> public void setOpts(java.util.List&lt; persistenceTest.Option &gt; _opts) { opts = _opts; } </code></p> <p>If there where a "addOpt(Option) method I could add the reference to User myself.</p> <p><code> public void addOpt(persistenceTest.Option __opts) { <strong> _opts.setUser_fk(this);</strong> optsList.add(_opts); } </code></p> <p>Am I thinking wrong or is it not possible to automate the creation of foreign keys?</p> <p>Best Regards Harald</p>HaraldWeberWed, 26 Mar 2014 10:25:39 -0400https://answers.axonivy.com/questions/588/persistence-api-foreign-key-is-always-nullpersistence