Jo nur generiere ich ja kein Statement mittels createQuery() sondern mache einfach immer ein session.save(meinModel) und hierbei tritt dann auch gleich die Exception auf - somit weiß ich leider nicht ganz genau wie ich gewünschtes anstellen soll. Meinst ich soll mittels createQuery() das Insert machen?
btw. danke für deine Mühen
**EDIT**
Hab nun ein Insert abgesetzt:
session.createSQLQuery("INSERT INTO AdvancedAddressModel (street) values (" + model.getStreet() + ")");
Nur scheint es keine Änderung in der DB zu geben.
Stacktrace:
29.05.2007 09:27:44 org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.4
29.05.2007 09:27:44 org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
29.05.2007 09:27:44 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
29.05.2007 09:27:44 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
29.05.2007 09:27:44 org.hibernate.cfg.Configuration configure
INFO: configuring from resource: hibernate.cfg.xml
29.05.2007 09:27:44 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: hibernate.cfg.xml
29.05.2007 09:27:45 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : at/pcd/wam/technologie/model/AdvancedAddressModel.hbm.xml
29.05.2007 09:27:45 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: at.pcd.wam.technologie.model.AdvancedAddressModel -> I_80050_SAVE
29.05.2007 09:27:45 org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
29.05.2007 09:27:45 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
29.05.2007 09:27:45 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
29.05.2007 09:27:45 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
29.05.2007 09:27:45 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.microsoft.sqlserver.jdbc.SQLServerDriver at URL: jdbc:sqlserver://mag2;databaseName=spc
29.05.2007 09:27:45 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=sa, password=****}
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: Microsoft SQL Server, version: 8.00.194
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: Microsoft SQL Server 2005 JDBC Driver, version: 1.1.1501.101
29.05.2007 09:27:45 org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.SQLServerDialect
29.05.2007 09:27:45 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
29.05.2007 09:27:45 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): enabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: auto
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL inserts for batching: disabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
29.05.2007 09:27:45 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JPA-QL strict compliance: disabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.NoCacheProvider
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Named query checking : enabled
29.05.2007 09:27:45 org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
29.05.2007 09:27:46 org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
29.05.2007 09:27:46 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: Running hbm2ddl schema update
29.05.2007 09:27:46 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: fetching database metadata
29.05.2007 09:27:46 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: updating schema
29.05.2007 09:27:46 org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: table found: spc.dbo.I_80050_SAVE
29.05.2007 09:27:46 org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: columns: [nichtdeutsch, nrid5, spam, zuname, strasse, aenderung, rid4, anforderung, geo_lat, rid2, geo_y, vorname, id, beschreibung, web, rid3, geschlecht, skype, erstellt, geo_x, ort, organisation, titel, funktion, mobiltel, gueltig, htmlmail, cc, geburtsdatum, geo_long, ear, rid1, n_rekey01, plz, telefon, bahnhof, geo, guid, email, review]
29.05.2007 09:27:46 org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: foreign keys: []
29.05.2007 09:27:46 org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: indexes: []
29.05.2007 09:27:46 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: schema update complete
**EDIT2**
v = SQLQueryImpl(INSERT INTO AdvancedAddressModel (street) values ('abcd'))
btw. danke für deine Mühen
**EDIT**
Hab nun ein Insert abgesetzt:
session.createSQLQuery("INSERT INTO AdvancedAddressModel (street) values (" + model.getStreet() + ")");
Nur scheint es keine Änderung in der DB zu geben.
Stacktrace:
29.05.2007 09:27:44 org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.4
29.05.2007 09:27:44 org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
29.05.2007 09:27:44 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
29.05.2007 09:27:44 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
29.05.2007 09:27:44 org.hibernate.cfg.Configuration configure
INFO: configuring from resource: hibernate.cfg.xml
29.05.2007 09:27:44 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: hibernate.cfg.xml
29.05.2007 09:27:45 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : at/pcd/wam/technologie/model/AdvancedAddressModel.hbm.xml
29.05.2007 09:27:45 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: at.pcd.wam.technologie.model.AdvancedAddressModel -> I_80050_SAVE
29.05.2007 09:27:45 org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
29.05.2007 09:27:45 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
29.05.2007 09:27:45 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
29.05.2007 09:27:45 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
29.05.2007 09:27:45 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.microsoft.sqlserver.jdbc.SQLServerDriver at URL: jdbc:sqlserver://mag2;databaseName=spc
29.05.2007 09:27:45 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=sa, password=****}
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: Microsoft SQL Server, version: 8.00.194
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: Microsoft SQL Server 2005 JDBC Driver, version: 1.1.1501.101
29.05.2007 09:27:45 org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.SQLServerDialect
29.05.2007 09:27:45 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
29.05.2007 09:27:45 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): enabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: auto
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL inserts for batching: disabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
29.05.2007 09:27:45 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JPA-QL strict compliance: disabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.NoCacheProvider
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
29.05.2007 09:27:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Named query checking : enabled
29.05.2007 09:27:45 org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
29.05.2007 09:27:46 org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
29.05.2007 09:27:46 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: Running hbm2ddl schema update
29.05.2007 09:27:46 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: fetching database metadata
29.05.2007 09:27:46 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: updating schema
29.05.2007 09:27:46 org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: table found: spc.dbo.I_80050_SAVE
29.05.2007 09:27:46 org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: columns: [nichtdeutsch, nrid5, spam, zuname, strasse, aenderung, rid4, anforderung, geo_lat, rid2, geo_y, vorname, id, beschreibung, web, rid3, geschlecht, skype, erstellt, geo_x, ort, organisation, titel, funktion, mobiltel, gueltig, htmlmail, cc, geburtsdatum, geo_long, ear, rid1, n_rekey01, plz, telefon, bahnhof, geo, guid, email, review]
29.05.2007 09:27:46 org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: foreign keys: []
29.05.2007 09:27:46 org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: indexes: []
29.05.2007 09:27:46 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: schema update complete
**EDIT2**
Code:
AdvancedAddressModel model = new AdvancedAddressModel();
model.setGeoLat("mpfTest");
model.setGeoLong("mpfTest");
// model.setLocality("mpfTest");
model.setStreet("abcd");
model.setZip("mpfTest");
model.setCountryCode("mpfTest mpfTest");
SQLQuery v = session.createSQLQuery("INSERT INTO AdvancedAddressModel (street) values ('" + model.getStreet() + "')");
// session.save(model);
tx.commit();
Zuletzt bearbeitet: