the mapping and session factory
<session-factory>
<property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
<property name="hibernate.cglib.use_reflection_optimizer">true</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="hibernate.connection.pool_size">1</property>
<property name="hibernate.show_sql">true</property>
<!-- General mapping associations -->
<mapping resource="Functions.hbm.xml" />
</session-factory>
The mapping file
<hibernate-mapping>
<class name="Functions" table="Functions" schema="dbo" catalog="common">
<id name="functionNb" type="character">
<column name="FunctionNb" length="10" />
<generator class="assigned" />
</id>
<property name="functionName" type="string">
<column name="FunctionName" length="250" />
</property>
<property name="niveau" type="integer">
<column name="Niveau" />
</property>
<property name="bg" type="integer">
<column name="bg" />
</property>
<property name="bd" type="integer">
<column name="bd" />
</property>
</class>
</hibernate-mapping>
and the code for the session factory
try {
// Create the SessionFactory from hibernate.cfg.xml
// sessionFactory = new Configuration().configure().buildSessionFactory();
sessionFactory = new Configuration().configure("file.cfg.xml").buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
Anyway, all the files have been generated by the artifact generator, and I haven"t modified anything. I've deliberately erased the DBs information in this posts but they are right since I can connect to it and retrieve records with all the other objects (well, with this one too but always the same reference)
Well actually, I've already found someone who already had the same problem on the forum but he resolved it by writing a full query ('select ... from') and not a simplified one ('from...'). Anyway, in my case, it's already a full query and using the eclipse tool, hql, or simplified queries doesn't change anything neither.
|