-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate re-loads an object without any change
PostPosted: Mon Dec 17, 2007 12:09 pm 
Newbie

Joined: Mon Dec 17, 2007 4:01 am
Posts: 1
Location: Israel
Hibernate version:3.2.3

Mapping documents:
hibernate.cfg.xml looks like this:
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>

      <!-- Database connection settings -->
      <property name="connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
      <property name="connection.url">jdbc:jtds:sqlserver://10.1.1.96/db_modelity_pension_bll;instance=SQLEXPRESS;charset=cp1255</property>
      <!-- property name="connection.url">jdbc:jtds:sqlserver://10.1.1.55/rating_model;charset=cp1255</property-->
      
      <property name="connection.username">pension</property>
      <property name="connection.password">123456</property>

      <!-- JDBC connection pool (use the built-in) -->
      <property name="connection.pool_size">1</property>

      <!-- SQL dialect -->
      <property name="dialect">org.hibernate.dialect.SQLServerDialect</property>

      <!-- Enable Hibernate's automatic session context management -->
      <property name="current_session_context_class">thread</property>
      
      <!-- Disable the second-level cache  -->
      <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

      <!-- Echo all executed SQL to stdout -->
      <property name="show_sql">true</property>
      <mapping resource="com/dal/orm/RatingModel.hbm.xml"/>
   </session-factory>

</hibernate-configuration>


RatingModel.hbm.xml looks like this:
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="com.blogic.ratingmodel.RatingModel"
      table="rm_rating_models">
      <id name="id" column="id">
            <generator class="org.hibernate.id.enhanced.TableGenerator">
            <param name="segment_value">rm_rating_models_sequence</param>
            <param name="initial_value">6</param>
         </generator>
      </id>
      <!-- property name="nameDvid" column="name_dvid"/-->
      <!-- property name="descriptionDvid" column="description_dvid"/-->
      <many-to-one name="domainSet" class="com.blogic.ratingmodel.groups.AssetGroupsSet" column="domain_set_id"/>
      <many-to-one name="thresholdSet" class="com.blogic.ratingmodel.groups.AssetGroupsSet" column="threshold_set_id"/>
      <property name="assetFundamentalsPageId" column="asset_fundamentals_page_id"/>
      <property name="targetAccountId" column="target_account_id"/>
      <many-to-one name="ratingIndicator" class="com.blogic.ratingmodel.indicators.GeneralRatingIndicator" column="rating_indicator_id"/>
      <property name="groupsHierarchyId" column="groups_hierarchy_id"/>
      <many-to-one name="squareRIndicator" class="com.blogic.ratingmodel.indicators.IndicatorInstance" column="square_r_indicator_instance_id"/>
      <many-to-one name="recentRun" class="com.blogic.ratingmodel.history.RatingModelRun" column="recently_run_id"/>
      <many-to-one name="recentPublishedRun" class="com.blogic.ratingmodel.history.RatingModelRun" column="recently_published_run_id"/>
      <many-to-one name="currentView" class="com.blogic.ratingmodel.history.ModelRunView" column="current_view_map_id"/>
   </class>
</hibernate-mapping>



Code between sessionFactory.openSession() and session.close():
RatingModel class use HibernateLoadable interface
this loads the RatingModel object:
Code:
      HibernateUtil.beginTransaction();
      currentModel =
         (RatingModel) HibernateUtil.load(RatingModel.class, modelId);
      currentModel.setLangId(langId);


and this is the function load of RatingModel class
Code:
   public void load() throws GeneralException
   {
      try
      {
      long start = System.currentTimeMillis();
      domainSet.setTargetAccountId(new Integer(SystemPreferences.getInstance().getValueByKeyword(RatingModelConstants.ALL_ASSETS_ACCOUNT_ID_KEYWORD)));
      thresholdSet.setTargetAccountId(targetAccountId);
      long startCreatHierarchy = System.currentTimeMillis();
      loadGroupHierarchy();
      long endCreatHierarchy = System.currentTimeMillis();
      loadProperties();
      loadIndicatorsHierarchy();
      squareRIndicator.load();
      long end = System.currentTimeMillis();
      if(resultsManager == null)
      {
         resultsManager = new ModelResultsManager();
      }
      isLoaded = true;
      }catch (Exception e) {
         e.printStackTrace();
      }
   }




Name and version of the database you are using:
sqlserver 2005


i dont know why Hibernate loads this object again and again... :-(
help plz :-)

_________________
Omri Cohen


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.