-->
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.  [ 3 posts ] 
Author Message
 Post subject: How to use SQLServer text type in hibernate?
PostPosted: Mon Mar 01, 2004 11:44 pm 
Newbie

Joined: Wed Feb 25, 2004 11:41 pm
Posts: 19
Location: China
I had looked through hibernate-doc and searched topics..but no answer found

I'm crazy now thx for your reply

I have one sqlserver table with a TEXT type field and some other fields
when I want insert some rows into .....all fields successful,TEXT field expected

follow my source sorry for my pool English^_^

hbm.xml:
<property name="intro" type="text" update="true" insert="true">
<column name="intro" sql-type="text"/>
</property>

java code:
Code:


-*-part of sample app:-*-
sm.beginTransaction();
    sm.session.save(sm.addCourse("1","test","TEXT HERE"));
    sm.session.flush();
    sm.endTransaction(true);

public Course addCourse(String id,String name,String intro)
  {
    Course course=new Course();
    course.setId(id);
    course.setName(name);
    course.setIntro(intro);
    return course;
  }


-*-Course.java-*
package stu;

public class Course
{

   private String id;
   private String name;
   private String intro;


   public void setId(String string) {
      id = string;
   }

   public String getId() {
      return id;
   }

   public void setName(String name)
   {
      this.name=name;
   }
   public String getName()
   {
      return this.name;
   }

        public void setIntro(String intro)
        {
                this.intro=intro;
        }
        public String getIntro()
        {
                return this.intro;
        }
   
}

_________________
who can tell me why?


Top
 Profile  
 
 Post subject: done
PostPosted: Tue Mar 02, 2004 3:18 am 
Newbie

Joined: Wed Feb 25, 2004 11:41 pm
Posts: 19
Location: China
<property name="intro" type="java.lang.String" update="true" insert="true" length="2147483647" >
<column name="intro" sql-type="text"/>
</property>

hope help

_________________
who can tell me why?


Top
 Profile  
 
 Post subject: Re: done
PostPosted: Tue Mar 02, 2004 5:29 am 
Proxool Developer
Proxool Developer

Joined: Tue Aug 26, 2003 10:42 am
Posts: 373
Location: Belgium
KaKaXi wrote:
<property name="intro" type="java.lang.String" update="true" insert="true" length="2147483647" >
<column name="intro" sql-type="text"/>
</property>

hope help


Strange... in our case the following simple mappings work like a charm:

Code:
<property name="intro" type="text" />


This is quite portable between DB (thx to Hibernate).


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.