-->
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.  [ 5 posts ] 
Author Message
 Post subject: how to save ntext column in sql server 2005?
PostPosted: Thu Oct 09, 2008 4:37 am 
Newbie

Joined: Mon Jun 20, 2005 11:14 pm
Posts: 13
Hibernate-Version: 3.2.4.sp1
database: microsoft sqlserver 2005
column: ntext

hbm.xml (mapping file)
<?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.armitage.royalGarden.system.SystemParameterBean" table="mt_system_parameter">
<id name="id" column="SysParaID">
<generator class="increment"/>
</id>

<property name="displayName">
<column name="SysParaDisplayName"/>
</property>

<property name="name">
<column name="SysParaName"/>
</property>

<property name="value" type="text" length="100000">
<column name="SysParaValue" />
</property>

<property name="type">
<column name="SysParaType"/>
</property>

<property name="createdBy">
<column name="CreatedBy"/>
</property>

<property name="createdAt">
<column name="CreatedDateTime"/>
</property>

<property name="lastUpdatedBy">
<column name="LastUpdatedBy"/>
</property>

<property name="lastUpdatedAt">
<column name="LastUpdateDateTime"/>
</property>
</class>

</hibernate-mapping>

java class
package com.abc.project1.system;

import java.util.Date;

public class SystemParameterBean {

private int id;
private String displayName;
private String name;
private String value;
private String type;
private String createdBy;
private Date createdAt;
private String lastUpdatedBy;
private Date lastUpdatedAt;

public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public String getLastUpdatedBy() {
return lastUpdatedBy;
}
public void setLastUpdatedBy(String lastUpdatedBy) {
this.lastUpdatedBy = lastUpdatedBy;
}
public Date getLastUpdatedAt() {
return lastUpdatedAt;
}
public void setLastUpdatedAt(Date lastUpdatedAt) {
this.lastUpdatedAt = lastUpdatedAt;
}

}

now my problem is the column "SysParaValue" can only save maximun 4000 characters!! any method to solve it?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 11, 2008 2:32 am 
Newbie

Joined: Mon Jun 20, 2005 11:14 pm
Posts: 13
it seems we can register a data type in hibernate using RegisterColumnType, but I don't know the implementation detail, anyone can help?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 13, 2008 4:15 am 
Newbie

Joined: Mon Jun 20, 2005 11:14 pm
Posts: 13
it seems so sad that no one can help, anyway I find the solution.

public class SQLServerDialectNText extends SQLServerDialect {

public SQLServerDialectNText(){
super();
registerColumnType( Types.LONGVARCHAR, "ntext" );
}
}

if using jdk1.6, should use LONGNVARCHAR instead of LONGVARCHAR

then in cfg.xml,
dialect should use "SQLServerDialectNText" instead of "SQLServerDialect"


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 13, 2008 4:17 am 
Newbie

Joined: Mon Jun 20, 2005 11:14 pm
Posts: 13
no need to change hbm.xml

<property name="value">
<column name="SysParaValue" />
</property>


Top
 Profile  
 
 Post subject: Re: how to save ntext column in sql server 2005?
PostPosted: Wed Jun 14, 2017 8:08 am 
Newbie

Joined: Thu Jul 10, 2008 6:45 am
Posts: 2
Location: Bangalore
Hi,

I am still getting the error :

Here is my Database Table :

id 4 int identity
langCode -9 nvarchar
tagName -9 nvarchar
tagValue -16 ntext
lastUpdated 93 smalldatetime

===My Entity:===

@Id
@Column(name="id")
private int id;
@Column(name="langCode")
private String langCode;
@Column(name="tagName")
private String tagName;
@Column(name="tagValue", columnDefinition="ntext", length=1073741823)
private String tagValue;
@Column(name="lastUpdated")
private Date lastUpdated;


==Overrident Dialact ==
with follwoing line :

registerColumnType(Types.LONGNVARCHAR, 1073741823, "ntext" );


And i Changed the Dialact to the overrident one with the above code.

I am still getting the same error :


17:28:13,731 ERROR [stderr] (http--127.0.0.1-8080-1) org.springframework.orm.jpa.JpaSystemException: No Dialect mapping for JDBC type: -9; nested exception is org.hibernate.MappingException: No Dialect mapping for JDBC type: -9


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