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:

"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".

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?

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.

How can we adress this issue?

Edit: RDBMS: MSSQL Express 2008

asked 17.06.2015 at 11:45

Nikel%20Weis's gravatar image

Nikel Weis
321262933
accept rate: 57%

edited 18.06.2015 at 14:01


There exists an utility which can set auto initialized data class values back to NULL. So you could use it to restore a valid state before you merge it to persistency. Its published here: http://sourceforge.net/ivySupplement/dataClassNuller

I did not test if this implementation still works with an up to date ivy version. So you have to verify and test it.

link

answered 22.06.2015 at 09:02

Reguel%20Wermelinger's gravatar image

Reguel Werme... ♦♦
7.8k11549
accept rate: 69%

edited 22.06.2015 at 09:03

I will try out the Data-Nuller - but it is a known problem that dates are auto-initialized even if the persistence returns NULL-values. So IVY's persistence wrapper manipulates data and makes it invalid for the source RDBMS? Am I correct in this interpretation?

(22.06.2015 at 11:22) Nikel Weis Nikel%20Weis's gravatar image

Faces similar problems here, we were able to save auto-initialized date but they were still a pain. Empty date became 0001-01-01.

I've fixed it when saving, nice, but now and then when we display a new object we still get 0001-01-01 date in p:calendar into the UI. We will probably find them elsewhere too I guess (data export, reports and the like).

We have to track every single one of them and fix them to make sure to display empty date. This is very annoying and not always obvious. It would be great that initialized/uninitialized state don't temper with the data itself.

If any global fix exist for that I would be interested.

link

answered 05.12.2016 at 20:16

RemiMorin's gravatar image

RemiMorin
216610
accept rate: 50%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×29

Asked: 17.06.2015 at 11:45

Seen: 1,599 times

Last updated: 05.12.2016 at 20:16