我在通过Spring Junit运行HSQLDB脚本时遇到异常。
我使用以下定义和技能来运行Junit。 HSQLDB脚本:架构定义
container.Register(
Component.For<IComponent2>()
.ImplementedBy<Component2>()
.DependsOn(Dependency.OnComponent<IComponent1, YourSpecialComponent1>())
);
Hibernate实体: ....
CREATE MEMORY TABLE MIGRATION."MIG_STATUS"("STATUS_ID" INTEGER NOT NULL,"STATUS_DESC" VARCHAR(255) COLLATE SQL_TEXT_UCC NOT NULL,CONSTRAINT "PK_MIG_STATUS" PRIMARY KEY("STATUS_ID"))
CREATE MEMORY TABLE MIGRATION."MIG_GROUP"("GROUP_ID" INTEGER NOT NULL,"GROUP_ATTEMPT_ID" INTEGER NOT NULL,"GROUP_NAME" VARCHAR(255) COLLATE SQL_TEXT_UCC,"EMAIL_IDS" VARCHAR(255) COLLATE SQL_TEXT_UCC,"FILE_CONTENT" BLOB(1G),"SCHEDULED_BY" VARCHAR(255) COLLATE SQL_TEXT_UCC,"SCHEDULED_AT" TIMESTAMP,"START_DATETIME" TIMESTAMP,"END_DATETIME" TIMESTAMP,"STATUS_ID" INTEGER,"MIGRATION_TYPE" VARCHAR(255) COLLATE SQL_TEXT_UCC NOT NULL,"PRE_CHECK_RUN_AT" TIMESTAMP,"PRE_CHECK_STATUS" INTEGER,CONSTRAINT "PK_MIG_GROUP" PRIMARY KEY("GROUP_ID","GROUP_ATTEMPT_ID"),CONSTRAINT "FK_GROUP_STATUS" FOREIGN KEY("STATUS_ID") REFERENCES MIGRATION."MIG_STATUS"("STATUS_ID"))
CREATE MEMORY TABLE MIGRATION."MIG_COMPANY"("COMPANY_ID" INTEGER NOT NULL,"ATTEMPT_ID" INTEGER NOT NULL,"GROUP_ID" INTEGER NOT NULL,"GROUP_ATTEMPT_ID" INTEGER NOT NULL,"COMPANY_NAME" VARCHAR(255) COLLATE SQL_TEXT_UCC,"USER_COUNT" INTEGER,"STATUS_ID" INTEGER,"START_DATETIME" TIMESTAMP,"END_DATETIME" TIMESTAMP,"MIGRATION_TYPE" VARCHAR(255) COLLATE SQL_TEXT_UCC NOT NULL,CONSTRAINT "PK_MIG_COMPANY" PRIMARY KEY("COMPANY_ID","ATTEMPT_ID"),CONSTRAINT "FK_COMPANY_MIG_GROUP" FOREIGN KEY("GROUP_ID","GROUP_ATTEMPT_ID") REFERENCES MIGRATION."MIG_GROUP"("GROUP_ID","GROUP_ATTEMPT_ID"),CONSTRAINT "FK_COMPANY_STATUS" FOREIGN KEY("STATUS_ID") REFERENCES MIGRATION."MIG_STATUS"("STATUS_ID"))
INSERT INTO MIG_STATUS VALUES(1,'Scheduled')
INSERT INTO "MIG_GROUP" VALUES(310,1,'mig_2274_mar4_v8',NULL,30,NULL,'2015-03-04 13:40:00.000000','2015-03-04 13:40:54.000000','2015-03-04 13:47:51.000000',201,'Forward',NULL,0)
INSERT INTO "MIG_COMPANY" VALUES(2274,5,310,1,'test31',0,400,'2015-03-04 13:40:53.000000','2015-03-04 13:47:51.000000','Forward')
第2课:
Class 1:
@Table(name = "MIG_COMPANY")
public class Company extends BaseObject implements Cloneable {
.....
@Expose
@ManyToOne(cascade = CascadeType.DETACH)
@JoinColumn(name = "STATUS_ID", nullable = false, insertable = true, updatable = true)
private Status status;
@ManyToOne
@JoinColumns({ @JoinColumn(name = "GROUP_ID"), @JoinColumn(name = "GROUP_ATTEMPT_ID") })
private Group group;
......
}
第3课:
@Table(name = "MIG_GROUP")
public class Group extends BaseObject {
.....
@Column(name = "FILE_CONTENT")
private byte[] fileContent;
.....
}
第4课:Junit电话
@Repository
public class CompanyDaoHibernate<E> implements CompanyDao<E> {
@Override
public Company getCompanyById(final int companyId, final int attemptId) {
final Session session = sessionFactory.getCurrentSession();
final Criteria criteria =
session.createCriteria(Company.class).add(Restrictions.eq("companyId", companyId))
.add(Restrictions.eq("attemptId", attemptId));
return (Company) criteria.uniqueResult();
}
}
错误
.....
{
companyManager.getCompanyById(2274, 5);
......
}
有人可以帮我搞错吗?