java - JPA DAO Update row without full row context -


have table >70 columns.

i use 8 of these columns .java object, including id - not sure if matters.

my id column has following:

@column(name = "pseudonym", nullable = false) @basic(fetch = fetchtype.eager) @id 

my question this:

if want update row using xxxdao.store(updatedrow) - need specify reference row id or missing here?

i'm getting following exception:

debug: org.springframework.web.servlet.dispatcherservlet - not complete request javax.persistence.persistenceexception: org.hibernate.exception.dataexception: not execute jdbc batch update .. ~(adding in here)~ not valid month 

hopefully have explained enough. let me know if haven't.

thanks in advance

some pseudo code reference:

item = dao.getitembyid(123); item.setupdatetime(thetime); dao.store(item); 

store: return getentitymanager().merge(itemtostore);


to clarify

i getting exception above not valid month. because trying update oracle table had column defined timestamp. trying pass string value (even though string structured identically).

in attempt debug this, question if update row via jpa dao without having e.g. 70+ columns defined in java object. turned out possible , exception not related not having defined columns. exception because timestamp trying update didn't have correct structure. changed strings date objects, , updated

my question this:

if want update row using xxxdao.store(updatedrow) - need specify reference row id or missing here?

answer

no - managed automatically, don't need specify identifier, , don't need create references columns in table either in java object.

item = dao.getitembyid(123); // item dao in database item.setupdatetime(thetime); // set/or change value dao.store(item); // contains merge(), , subsequently flush() 

item contains reference row updated.


additionally, when dealing timestamps in sql table, ensure actual date objects , not strings.

when pulling date string read fine. if want update row in future via merge, string not work. value date re-passed again (as string), , cause exception thrown (e.g. not valid month). ensure dates/timestamps stored date objects opposed strings , perhaps tostring them on ui.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -