NutzCN Logo
问答 Oracle复合主键报错
发布于 2876天前 作者 老司机 1494 次浏览 复制 上一个帖子 下一个帖子
标签:

RT,先贴上entity

@Table("t_district")
@PK({"district_code","district_name_cn"})
public class District extends BaseEntity {
	@Column
	String district_code;
	@Column
	String district_name_cn;
	@Column
	short district_level;
	@Column
	String parent_district_code;
	@Column
	String district_code_path;
	@Column
	String district_name_path;
	@Column
	String zipcode;
}

下面是log

2017-2-7 10:59:33.653 DEBUG [main] CREATE TABLE t_district(
district_code VARCHAR2(128),
district_name_cn VARCHAR2(128),
district_level NUMBER(4),
parent_district_code VARCHAR2(128),
district_code_path VARCHAR2(128),
district_name_path VARCHAR2(128),
zipcode VARCHAR2(128),
version_no NUMBER NOT NULL,
create_by VARCHAR2(128),
create_date DATE,
update_by VARCHAR2(128),
update_date DATE,
remarks VARCHAR2(128),
del_flag CHAR(4))
2017-2-7 10:59:33.674 DEBUG [main] alter table t_district add constraint primary_key__district_code_district_name_c primary key (district_code,district_name_cn)
2017-2-7 10:59:33.677 DEBUG [main] SQLException
java.sql.SQLSyntaxErrorException: ORA-00972: 标识符过长

	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450)
	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399)
	at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1059)
	at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:522)
	at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:257)
	at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:587)
	at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:210)
	at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:30)
	at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:931)
	at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1150)
	at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1792)
	at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1745)
	at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:334)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor._runStatement(NutDaoExecutor.java:357)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:60)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66)
	at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
	at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:158)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithTransaction(NutDaoRunner.java:104)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:88)
	at org.nutz.dao.impl.sql.run.NutDaoRunner$1.run(NutDaoRunner.java:74)
	at org.nutz.trans.Trans.exec(Trans.java:174)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:72)
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:240)
	at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:248)
	at org.nutz.dao.impl.DaoSupport.execute(DaoSupport.java:236)
	at org.nutz.dao.impl.jdbc.oracle.OracleJdbcExpert.createEntity(OracleJdbcExpert.java:137)
	at org.nutz.dao.impl.EntityHolder.reloadEntity(EntityHolder.java:86)
	at org.nutz.dao.impl.NutDao.create(NutDao.java:784)
	at org.nutz.dao.util.Daos.createTablesInPackage(Daos.java:539)
	at db.App.main(App.java:17)
4 回复

... 没想到...

要不这样写

	@Column("dc")
	String district_code;
	@Column("dnc")
	String district_name_cn;

可以的,但是上面要求列名得那么长,咋整?

那感觉上只能自己建个表了

添加回复
请先登陆
回到顶部