I have a problem persisting a simple object. Jugding by the console output it seems fine but no changes to db are being made.
Here are the files
hibernate.cfg.xml
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="hibernate.connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
<property name="hibernate.connection.url">jdbc:microsoft:sqlserver://localhost;DataBaseName=Proba;User=Boris;Password=Boris</property>
<property name="hibernate.connection.username">Boris</property>
<property name="hibernate.connection.password">Boris</property>
<property name="show_sql">true</property>
<property name="transaction.factory_class">
org.hibernate.transaction.JDBCTransactionFactory
</property>
<property name="hibernate.cache.provider_class">
org.hibernate.cache.HashtableCacheProvider
</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<mapping resource="Student.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Student.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="Student" table="Studenti">
<id name="id" column="brojIndeksa" type="long">
</id>
<property name="ime" column="Ime" type="java.lang.String" not-null="true"/>
<property name="prezime" column="Prezime" type="java.lang.String" not-null="true"/>
</class>
</hibernate-mapping>
relevant code
Code:
SessionFactory sf = new Configuration().configure().buildSessionFactory();
Session sesija = sf.openSession();
Student student;
Student s = new Student(new Long(1000),"Marvin","Monroe");
Transaction tx = sesija.beginTransaction();
try
{
tx = sesija.beginTransaction();
sesija.persist(s);
tx.commit();
}
catch (HibernateException e)
{
e.printStackTrace();
}
finally {sesija.flush();}
student = (Student)sesija.load(Student.class,new Long(1000));
System.out.print(student.toString());
sesija.close();
sf.close();
and the console output
Code:
May 3, 2005 12:48:49 AM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.0.1
May 3, 2005 12:48:49 AM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
May 3, 2005 12:48:49 AM org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
May 3, 2005 12:48:49 AM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
May 3, 2005 12:48:49 AM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
May 3, 2005 12:48:49 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
May 3, 2005 12:48:50 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: Student.hbm.xml
May 3, 2005 12:48:50 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: Student -> Studenti
May 3, 2005 12:48:50 AM org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
May 3, 2005 12:48:50 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing extends queue
May 3, 2005 12:48:50 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing collection mappings
May 3, 2005 12:48:50 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing association property references
May 3, 2005 12:48:50 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
May 3, 2005 12:48:50 AM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.SQLServerDialect
May 3, 2005 12:48:50 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
May 3, 2005 12:48:50 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
May 3, 2005 12:48:50 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
May 3, 2005 12:48:50 AM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
May 3, 2005 12:48:50 AM org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
May 3, 2005 12:48:50 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
May 3, 2005 12:48:50 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
May 3, 2005 12:48:50 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
May 3, 2005 12:48:50 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
May 3, 2005 12:48:50 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.microsoft.jdbc.sqlserver.SQLServerDriver at URL: jdbc:microsoft:sqlserver://localhost;DataBaseName=Proba;User=Boris;Password=Boris
May 3, 2005 12:48:50 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=Boris, password=****}
May 3, 2005 12:48:50 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
May 3, 2005 12:48:50 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): disabled
May 3, 2005 12:48:50 AM org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
May 3, 2005 12:48:50 AM org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
May 3, 2005 12:48:50 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
May 3, 2005 12:48:50 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
May 3, 2005 12:48:50 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
May 3, 2005 12:48:50 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
May 3, 2005 12:48:50 AM org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.HashtableCacheProvider
May 3, 2005 12:48:50 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
May 3, 2005 12:48:50 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: enabled
May 3, 2005 12:48:50 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Echoing all SQL to stdout
May 3, 2005 12:48:50 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
May 3, 2005 12:48:50 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
May 3, 2005 12:48:50 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
May 3, 2005 12:48:51 AM org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
May 3, 2005 12:48:51 AM org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
May 3, 2005 12:48:51 AM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.SQLServerDialect
May 3, 2005 12:48:51 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
May 3, 2005 12:48:51 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
May 3, 2005 12:48:51 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
May 3, 2005 12:48:51 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.microsoft.jdbc.sqlserver.SQLServerDriver at URL: jdbc:microsoft:sqlserver://localhost;DataBaseName=Proba;User=Boris;Password=Boris
May 3, 2005 12:48:51 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=Boris, password=****}
May 3, 2005 12:48:51 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: Running hbm2ddl schema update
May 3, 2005 12:48:51 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: fetching database metadata
May 3, 2005 12:48:51 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: updating schema
May 3, 2005 12:48:51 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing extends queue
May 3, 2005 12:48:51 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing collection mappings
May 3, 2005 12:48:51 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing association property references
May 3, 2005 12:48:51 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
May 3, 2005 12:48:51 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: table found: Proba.dbo.Studenti
May 3, 2005 12:48:51 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: columns: [brojindeksa, ime, prezime]
May 3, 2005 12:48:51 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: foreign keys: []
May 3, 2005 12:48:51 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: indexes: [pk_student]
May 3, 2005 12:48:51 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: schema update complete
May 3, 2005 12:48:51 AM org.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:microsoft:sqlserver://localhost;DataBaseName=Proba;User=Boris;Password=Boris
May 3, 2005 12:48:51 AM org.hibernate.impl.SessionFactoryImpl checkNamedQueries
INFO: Checking 0 named queries
Hibernate: select student0_.brojIndeksa as brojInde1_0_, student0_.Ime as Ime0_0_, student0_.Prezime as Prezime0_0_ from Studenti student0_ where student0_.brojIndeksa=?
9088 Boris Jockov
Hibernate: insert into Studenti (Ime, Prezime, brojIndeksa) values (?, ?, ?)
1000 Marvin Monroe
May 3, 2005 12:49:18 AM org.hibernate.util.JDBCExceptionReporter logWarnings
WARNING: SQL Warning: 0, SQLState:
May 3, 2005 12:49:18 AM org.hibernate.util.JDBCExceptionReporter logWarnings
WARNING: [Microsoft][SQLServer 2000 Driver for JDBC]Database changed to Proba
May 3, 2005 12:49:18 AM org.hibernate.util.JDBCExceptionReporter logWarnings
WARNING: SQL Warning: 0, SQLState:
May 3, 2005 12:49:18 AM org.hibernate.util.JDBCExceptionReporter logWarnings
WARNING: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Changed database context to 'Proba'.
May 3, 2005 12:49:18 AM org.hibernate.util.JDBCExceptionReporter logWarnings
WARNING: SQL Warning: 0, SQLState:
May 3, 2005 12:49:18 AM org.hibernate.util.JDBCExceptionReporter logWarnings
WARNING: [Microsoft][SQLServer 2000 Driver for JDBC]Language changed to us_english
May 3, 2005 12:49:18 AM org.hibernate.util.JDBCExceptionReporter logWarnings
WARNING: SQL Warning: 0, SQLState:
May 3, 2005 12:49:18 AM org.hibernate.util.JDBCExceptionReporter logWarnings
WARNING: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Changed language setting to us_english.
May 3, 2005 12:49:23 AM org.hibernate.impl.SessionFactoryImpl close
INFO: closing
May 3, 2005 12:49:23 AM org.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:microsoft:sqlserver://localhost;DataBaseName=Proba;User=Boris;Password=Boris
im using ms sql server 2000 and ms jdbc driver. Loading objects from db works fine but saving them does not.
What am i missing?
thanks