采用得是oracle9i数据库,jboss或weblogic。
jdbc采用oracle9i自带的class12.jar
-------------
数据库结构:
代码:
create table sncparameters
(
id number(19) not null,
sncid number(19),
name varchar2(255),
value clob
)
--------------
bo采用xdoclet建立的:
代码:
public class sncparameters extends baseobject
{
/**
* returns the id.
*
* @return long
* @hibernate.id
* column = "id"
* type = "long"
* generator-class = "native"
* unsaved-value = "null"
*/
public long getid()
{
return id;
}
/**
* sets the id attribute of the sncparameters object
*
* @param id the new id value
*/
public void setid(long id)
{
this.id = id;
}
/**
* returns the name.
*
* @return string
*
* @hibernate.property
* column = "name"
* type = "string"
* not-null = "true"
* unique = "false"
*/
public string getname()
{
return name;
}
/**
* sets the name attribute of the sncparameters object
*
* @param name the new name value
*/
public void setname(string name)
{
this.name = name;
}
/**
* returns the sncid.
*
* @return long
*
* @hibernate.property
* column = "sncid"
* type = "long"
* not-null = "true"
* unique = "false"
*/
public long getsncid()
{
return sncid;
}
/**
* sets the sncid attribute of the sncparameters object
*
* @param sncid the new sncid value
*/
public void setsncid(long sncid)
{
this.sncid = sncid;
}
/**
* returns the values.
*
* @return clob
*
* @hibernate.property
* column = "value"
* type = "clob"
* not-null = "true"
* unique = "false"
*/
public clob getvalue()
{
return value;
}
/**
* sets the values attribute of the sncparameters object
*
* @param values the new values value
*/
public void setvalue(clob value)
{
this.value = value;
}
private long id;
private long sncid;
private string name;
private clob value;
private string valuestring;
public string getvaluestring()
{
return valuestring;
}
public void setvaluestring(string valuestring)
{
this.valuestring = valuestring;
}
}
注:valuestring并不映射到数据库的clob字段,只是方便需要使用这个bo的人用get、set 处理这个巨长的clob字段
------------
xdoclet生成的xml文件:
代码:
<?xml version="1.0"?>
<!doctype hibernate-mapping public
"-//hibernate/hibernate mapping dtd 2.0//en"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class
name="com.idncn.mc.bo.sncparameters"
table="sncparameters"
dynamic-update="false"
dynamic-insert="false"
>
<id
name="id"
column="id"
type="long"
unsaved-value="null"
>
<generator class="native">
</generator>
</id>
<property
name="name"
type="string"
update="true"
insert="true"
column="name"
not-null="true"
unique="false"
/>
<property
name="sncid"
type="long"
update="true"
insert="true"
column="sncid"
not-null="true"
unique="false"
/>
<property
name="value"
type="clob"
update="true"
insert="true"
column="value"
not-null="true"
unique="false"
/>
</class>
</hibernate-mapping>
--------------------
insert的代码:
代码:
public list batchaddsncparameters(list sncparameterslist, long sncid) throws dbaccessexception
{
logger.entermethod();
list ret = new arraylist();
try
{
sess = getsession();
if (sncparameterslist != null && sncparameterslist.size() > 0)
{
for (int i = 0; i < sncparameterslist.size(); i++)
{
sncparameters cp = (sncparameters) sncparameterslist.get(i);
long newid = -1;
if (cp != null)
{
sncparameters cpnew = new sncparameters();
cpnew.setsncid(sncid);
cpnew.setname(cp.getname());
cpnew.setvalue(hibernate.createclob(" "));
newid = ((long) sess.save(cpnew)).longvalue();
sess.flush();
sess.refresh(cpnew, lockmode.upgrade);
string content = cp.getvaluestring();
string appserver = system.getproperty("appserver", "jboss");
if (!appserver.equalsignorecase("jboss"))
{
//weblogic
oraclethinclob clob = (oraclethinclob) cpnew.getvalue();
java.io.writer pw = clob.getcharacteroutputstream();
pw.write(content);
pw.flush();
pw.close();
}
else
{
//jboss
oracle.sql.clob clob = (oracle.sql.clob) cpnew.getvalue();
java.io.writer pw = clob.getcharacteroutputstream();
pw.write(content)
闽公网安备 35060202000074号