当前位置:编程学习 > JAVA >>

hibernate中用oracle nvarchar2数据类型

在hibernate中写原生sql,不支持oracle的nvarchar2数据类型,不知道有人有解决方案不? hibernate oracle sql nvarchar2 --------------------编程问答-------------------- sql 发出来啊 亲 还有错误信息啥的 --------------------编程问答-------------------- 这是这个表的结构:

  CREATE TABLE "ISM_ACCOUNT"."REPORT_TABLE_COL_CHECK" 
   ( "ID" NUMBER(10,0) NOT NULL ENABLE, 
"TABLE_TYPE" NVARCHAR2(10) NOT NULL ENABLE, 
"NULLABLE" NUMBER(1,0), 
"MAX_LENGTH" NUMBER(10,0), 
"WORD_BOOK" NVARCHAR2(20), 
"COLUMN_NUMBER" NUMBER(5,0), 
"COLUMN_NAME" NVARCHAR2(60), 
"CREATE_TIME" DATE DEFAULT sysdate, 
"LAST_TIME" TIMESTAMP (6), 
"META_COLUMN_ID" NUMBER(10,0), 
"NULLABLE_MESSAGE" CLOB, 
"MAX_LEN_MESSAGE" NVARCHAR2(1000), 
"WORD_BOOK_MESSAGE" CLOB, 
"CHECKER_ID" NVARCHAR2(255)



实体:



/**
 * ReportTableColCheck entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "REPORT_TABLE_COL_CHECK", schema = "ISM_ACCOUNT")
public class ReportTableColCheck implements java.io.Serializable {

// Fields
private static final long serialVersionUID = 4932172468128075092L;
private Long id;
private String tableType;
private Byte nullable;
private Long maxLength;
private String wordBook;
private Byte columnNumber;
private String columnName;
private Timestamp createTime;
private Timestamp lastTime;
private Long metaColumnId;
private String nullableMessage;
private String maxLenMessage;
private String wordBookMessage;
private String checkerId;

// Constructors

/** default constructor */
public ReportTableColCheck() {
}

/** minimal constructor */
public ReportTableColCheck(String tableType) {
this.tableType = tableType;
}

// Property accessors
@SequenceGenerator(name = "generator",sequenceName="S_REPORT_TABLE_COL_CHECK")
@Id
@GeneratedValue(strategy = SEQUENCE, generator = "generator")
@Column(name = "ID", unique = true, nullable = false, precision = 10, scale = 0)
public Long getId() {
return this.id;
}

public void setId(Long id) {
this.id = id;
}

@Column(name = "TABLE_TYPE", nullable = false, length = 10)
public String getTableType() {
return this.tableType;
}

public void setTableType(String tableType) {
this.tableType = tableType;
}

@Column(name = "NULLABLE", precision = 1, scale = 0)
public Byte getNullable() {
return this.nullable;
}

public void setNullable(Byte nullable) {
this.nullable = nullable;
}

@Column(name = "MAX_LENGTH", precision = 10, scale = 0)
public Long getMaxLength() {
return this.maxLength;
}

public void setMaxLength(Long maxLength) {
this.maxLength = maxLength;
}

@Column(name = "WORD_BOOK", length = 20)
public String getWordBook() {
return this.wordBook;
}

public void setWordBook(String wordBook) {
this.wordBook = wordBook;
}

@Column(name = "COLUMN_NUMBER", precision = 5, scale = 0)
public Byte getColumnNumber() {
return this.columnNumber;
}

public void setColumnNumber(Byte columnNumber) {
this.columnNumber = columnNumber;
}

@Column(name = "COLUMN_NAME", length = 60)
public String getColumnName() {
return this.columnName;
}

public void setColumnName(String columnName) {
this.columnName = columnName;
}

@Column(name = "CREATE_TIME", length = 7)
public Timestamp getCreateTime() {
return this.createTime;
}

public void setCreateTime(Timestamp createTime) {
this.createTime = createTime;
}

@Column(name = "LAST_TIME", length = 7)
public Timestamp getLastTime() {
return this.lastTime;
}

public void setLastTime(Timestamp lastTime) {
this.lastTime = lastTime;
}

@Column(name = "META_COLUMN_ID", precision = 10, scale = 0)
public Long getMetaColumnId() {
return this.metaColumnId;
}

public void setMetaColumnId(Long metaColumnId) {
this.metaColumnId = metaColumnId;
}

@Column(name = "NULLABLE_MESSAGE")
public String getNullableMessage() {
return this.nullableMessage;
}

public void setNullableMessage(String nullableMessage) {
this.nullableMessage = nullableMessage;
}

@Column(name = "MAX_LEN_MESSAGE", length = 20)
public String getMaxLenMessage() {
return this.maxLenMessage;
}

public void setMaxLenMessage(String maxLenMessage) {
this.maxLenMessage = maxLenMessage;
}

@Column(name = "WORD_BOOK_MESSAGE")
public String getWordBookMessage() {
return this.wordBookMessage;
}

public void setWordBookMessage(String wordBookMessage) {
this.wordBookMessage = wordBookMessage;
}

@Column(name = "CHECKER_ID")
public String getCheckerId() {
return this.checkerId;
}

public void setCheckerId(String checkerId) {
this.checkerId = checkerId;
}

}


这是查询的java方法:

public List<ReportTableColumnNumber> findReportTableNumber() {
List<ReportTableColumnNumber> resList = new ArrayList<ReportTableColumnNumber>();
String reportTableHqlByType = "select table_type, count(table_type) nums from report_table_col_check group by table_type order by table_type ";
Query query = getSession().createSQLQuery(reportTableHqlByType);
// String reportTableHqlByType = "select tableType, count(tableType) from ReportTableColCheck group by tableType order by tableType ";
// Query query = getSession().createQuery(reportTableHqlByType);
List<?> list = query.list();
for (int i = 0; i < list.size(); i++) {
ReportTableColumnNumber rn = new ReportTableColumnNumber();
Object[] ovalue = (Object[])list.get(i);
String type = (String) ovalue[0];
BigDecimal  nums = (BigDecimal) ovalue[1];
// Long  nums = (Long) ovalue[1];
rn.setTableCode(type);
rn.setColumnNumber(String.valueOf(nums.longValue()));
resList.add(rn);
}
return resList;
}


这是报错:
No Dialect mapping for JDBC type :-9 --------------------编程问答-------------------- http://hi.baidu.com/deng1259070/item/cb63704396e73aaf61d7b9d8

可以参考上面的?
你用的什么数据库?mysql,oracle? --------------------编程问答-------------------- oracle --------------------编程问答-------------------- http://blog.csdn.net/xd195666916/article/details/5419316
参考 --------------------编程问答-------------------- 不知你dialect没有配置。
补充:Java ,  Web 开发
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,