kochcp wrote:
there is a native option for the generator tag
Yes, i know ;) i tried this...and all the other "possible" options...Let me show you my id-tag:
<id
name="Id"
column="__Org_RecordNo"
type="long"
unsaved-value="null">
<generator class="native"/>
</id>
the id-column (__Org_Re....) is sql-type integer..and in Microsoft SQL there is a option for primary key called :"is identity - yes/no" and the setting is "yes".. and it is not allowed to me to change it into "no" in coz of other applications...
But for testing i changed one time to "no"...and i was able to record data´s. But in given situation and my actuall mapping i always get following exception:
net.sf.hibernate.exception.GenericJDBCException: could not insert: [de.consistec.Ansprech_Partner.Adressen]
at net.sf.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:80)
at net.sf.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:69)
at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at net.sf.hibernate.persister.AbstractEntityPersister.convert(AbstractEntityPersister.java:1331)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:540)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:426)
at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:28)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2449)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:943)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:868)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:786)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:749)
at de.consistec.Ansprech_Partner.InsertTests.NeueAdressen(InsertTests.java:54)
at de.consistec.Ansprech_Partner.InsertTests.main(InsertTests.java:101)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The statement must be executed before the generated keys are available
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getGeneratedKeys(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.sf.hibernate.util.GetGeneratedKeysHelper.getGeneratedKey(GetGeneratedKeysHelper.java:59)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:520)
... 9 more
also when i try
<generator class="identity"/> (should normaly work with mssql)
i get the same message as above...
THX ;)