Questions Tagged With persistencehttps://answers.axonivy.com/tags/persistence/?type=rss&user=Nikel%20Weisquestions tagged <span class="tag">persistence</span>enThu, 18 Jun 2015 14:11:26 -0400How to delete a dependent persistence object?https://answers.axonivy.com/questions/1371/how-to-delete-a-dependent-persistence-object<p>We have a persistence object A which has a property <code>List(Object b)</code>.</p> <p>When we remove one object b from the list with:</p> <pre><code>out.questionnaireConcept.QuestionnaireConceptParticpants.remove(in.participantToRemove); </code></pre> <p>and then try to persist this with:</p> <pre><code>ivy.persistence.***MuPersistence.merge(in.questionnaireConcept); </code></pre> <p>The participant which we tried to remove is still present in the database. I thought this could be set within the persistence definition in this window:</p> <p><img alt="alt text" src="http://answers.axonivy.com/upfiles/Unbenannt_6vIaC2d.PNG"></p> <p>Do we have to remove the object b separately from the database or how can we achieve this?</p>Nikel WeisThu, 18 Jun 2015 14:11:26 -0400https://answers.axonivy.com/questions/1371/how-to-delete-a-dependent-persistence-objectpersistenceHow to work with NULL-Values in DateTime-Types using persistence?https://answers.axonivy.com/questions/1369/how-to-work-with-null-values-in-datetime-types-using-persistence<p>We are facing the following problem: We are using the persistence-feature to handle complex objects. During the fetch we get values where a datetime-field is not set (NULL in the database) - when we try to write the entity object instance back to the database (merge) we get the following exception:</p> <pre><code>"SQLException: Only dates between January 1, 1753 and December 31, 9999 are accepted. DataException: could not update: [de.*****.qia.persistence.QuestionnaireQuestion#130] PersistenceException: org.hibernate.exception.DataException: could not update: [de.*****.qia.persistence.QuestionnaireQuestion#130] RollbackException: Error while committing the transaction Failed to excecute operation "merge" for persistence unit "qiaPersistence". </code></pre> <p>The reason is quite obvious - the auto-initialized value is out of the allowed range for the MSSQL-Server. But shouldn't NULL be the value to be written back?</p> <p>How can we adress this? A workaround would be to enforce that a date is created during the initial persist but there could be situation where "NULL" is programmtically a valid entry.</p> <p>How can we adress this issue?</p> <p>Edit: RDBMS: MSSQL Express 2008</p>Nikel WeisWed, 17 Jun 2015 11:45:23 -0400https://answers.axonivy.com/questions/1369/how-to-work-with-null-values-in-datetime-types-using-persistencepersistenceWhich data-type can we use to save a file to a database using the IvyPersistence?https://answers.axonivy.com/questions/1336/which-data-type-can-we-use-to-save-a-file-to-a-database-using-the-ivypersistence<p>Currently we are trying to write a file to the database using Ivy's persistence API - which data-type can we use to achieve this or do we have to use a plain SQL-Step?</p>Nikel WeisTue, 26 May 2015 12:15:02 -0400https://answers.axonivy.com/questions/1336/which-data-type-can-we-use-to-save-a-file-to-a-database-using-the-ivypersistencepersistencePersistence Object is not saved - ForeignKey is Null.https://answers.axonivy.com/questions/667/persistence-object-is-not-saved-foreignkey-is-null<p>We have two persistence objects where a hasMany b. So a is a property of b.</p> <p>Now we are creating an object of type b and asign the corresponding a-object to b. </p> <pre><code>b.a = a; </code></pre> <p>Then we try to save the newly created b object via:</p> <pre><code>ivy.persistence.persistenceUnit.merge(b); </code></pre> <p>Then it throws an error that the ForeignKey of a in table b cannot be null. But in the debugger object a is assigned correctly to object b.</p> <p>In which pitfall did I run here?</p>Nikel WeisTue, 29 Apr 2014 08:45:16 -0400https://answers.axonivy.com/questions/667/persistence-object-is-not-saved-foreignkey-is-nullpersistenceIs it possible to create an ivy persistence object from String?https://answers.axonivy.com/questions/658/is-it-possible-to-create-an-ivy-persistence-object-from-string<p>Usually a persistence object is created via:</p> <pre><code>import objects.Product; // persist new created product Product product; product.name = "Product name"; product.nr = 12; ivy.persistence.webshpo.persist(product); </code></pre> <p>What we are trying to do (for a dynamic interface) to dynamically create the persistence object with something like:</p> <pre><code>Object persistenceObject = Class.forName(in.persistenceClassName).newInstance(); </code></pre> <p>Is that generally possible? Can that be achieved in a ScriptStep or just in a JavaClass?</p> <p>Edit: We tried to give the full package name in the code mentioned above which returns a ClassNotFoundException:</p> <p>Object persistenceObject = Class.forName("objects.Product").newInstance();</p> <p>Edit 2: Changed persistenceUnit naming to persistenceObject according to Daniel's comment.</p>Nikel WeisFri, 25 Apr 2014 10:39:01 -0400https://answers.axonivy.com/questions/658/is-it-possible-to-create-an-ivy-persistence-object-from-stringpersistenceIs it possible to apply field order of a persistent data-class to database table?https://answers.axonivy.com/questions/650/is-it-possible-to-apply-field-order-of-a-persistent-data-class-to-database-table<p>I've noticed that if I use the persistence API to create a database table the order of the table columns is not the same as in the persistence data-class. Is it possible to keep the field order in a data-class to a database table?</p>Nikel WeisThu, 24 Apr 2014 10:29:21 -0400https://answers.axonivy.com/questions/650/is-it-possible-to-apply-field-order-of-a-persistent-data-class-to-database-tablepersistenceEndless circular relation in 1:n relation correct?https://answers.axonivy.com/questions/643/endless-circular-relation-in-1-n-relation-correct<p>I've a 1:n relation defined using the persistence api. One customer has n delivery adresses. In the history object this appears as customer object who has a list of delivery addresses. Those delivery addresses themself also have a customer attached and that customer a list of delivery addresses and so on and so forth. While this is semantically correct im wondering if I did something wrong or is this correct?</p>Nikel WeisThu, 17 Apr 2014 08:43:07 -0400https://answers.axonivy.com/questions/643/endless-circular-relation-in-1-n-relation-correctpersistence