-->
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.  [ 2 posts ] 
Author Message
 Post subject: It's possible this?
PostPosted: Mon Mar 07, 2005 6:16 am 
Regular
Regular

Joined: Thu Feb 24, 2005 2:34 pm
Posts: 80
HI,
i have a simple class
Code:
package vo.as400;



public class CStagione implements java.io.Serializable {

  private String cdc_stag;
  private String dsc_stag;



  public String _remoteClass = "vo.as400.CStagione";
  public String getCdc_stag() {
    return cdc_stag;
  }

  public void setDsc_stag(String dsc_stag) {
    this.dsc_stag = dsc_stag;
  }

  public void setCdc_stag(String cdc_stag) {
    this.cdc_stag = cdc_stag;
  }


  public String getDsc_stag() {
    return dsc_stag;
  }


}


and my dao class
Code:
public CStagione[] getAllSeason_ok() throws DaoException {
    try
    {
      Connection conn=ConnectionFactory.getInstance().getConn();
      Session session = FirebirdSession.currentSession();

      PreparedStatement stmt = session.connection().prepareStatement("Select TRIM(CDELTB),SUBSTR(DATITB,1,30) from "arctb00f Where cdtbtb='STG' AND STRETB=''  Order by 1 ");
      ResultSet rset = stmt.executeQuery();
      ArrayList list = new ArrayList();
      CStagione season = null;
      for (; rset.next(); list.add(season))
      {
        season = new CStagione();
        season.setCdc_stag(rset.getString(1));
        season.setDsc_stag(rset.getString(2));
      }
      rset.close();
      stmt.close();
      FirebirdSession.currentSession();
      CStagione seasons[] = new CStagione[list.size()];
//      conn.close();
      list.toArray(seasons);
      return seasons;
    }
    catch (Exception ex) {
      ex.printStackTrace();
      throw new java.lang.UnsupportedOperationException("CStagioneDao getAllSeason "+ex.getMessage());
    }
  }


It's possible to use hibernate for to get this result? can you help me with a mapping please
Devis


Top
 Profile  
 
 Post subject: I have resolved my problem in this way
PostPosted: Wed Mar 09, 2005 1:01 pm 
Regular
Regular

Joined: Thu Feb 24, 2005 2:34 pm
Posts: 80
Hi,


Code:
package vo.as400;



public class CStagione implements java.io.Serializable {

  private String cdc_stag;
  private String dsc_stag;



  public String _remoteClass = "vo.as400.CStagione";
  public String getCdc_stag() {
    return cdc_stag;
  }

  public void setDsc_stag(String dsc_stag) {
    this.dsc_stag = dsc_stag.substring(0,30);
  }

  public void setCdc_stag(String cdc_stag) {
    this.cdc_stag = cdc_stag;
  }


  public String getDsc_stag() {
    return dsc_stag;
  }

}





<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>


   <class name="vo.as400.CStagione" table="sdgtwb_dat.arctb00f" lazy="false">


     <id name="cdc_stag" column="cdeltb" >
             <generator class="assigned"/>
       </id>

<property name="dsc_stag"  column="DATITB" type="string" />



   <filter name="stagione" condition="CDTBTB IN (:tipo)"/>

        </class>

<filter-def name="stagione">
<filter-param name="tipo" type="string"/>
</filter-def>

</hibernate-mapping>





Emaple Dao

session.enableFilter("stagione").setParameter("tipo",new String("STG"));
Query q = session.createQuery("from CStagione as ay ");



Bye devis

ps.
have any idea how to implement TRIM by hibernate without use pojo


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

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.