我有一個問題映射到我的web應用程序,我有一個表(TacheTicket)包含兩個主鍵和映射文件,我把下列代碼:映射休眠:<複合-ID> 3
<hibernate-mapping>
<class name="com.model.TacheTicket" table="TACHETICKET">
<composite-id>
<key-property name="idTache" column ="idTache" type="com.model.Tache"/>
<key-property name="idTicket" column="idTicket" type="com.model.Ticket"/>
</composite-id>
</class>
</hibernate-mapping>
但當我執行該程序時出現此錯誤:
org.hibernate.MappingException: Could not determine type for: com.model.Tache, at table: TACHETICKET, for columns: [org.hibernate.mapping.Column(idTache)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:269)
at org.hibernate.tuple.PropertyFactory.buildStandardProperty(PropertyFactory.java:120)
at org.hibernate.tuple.component.ComponentMetamodel.<init>(ComponentMetamodel.java:45)
at org.hibernate.mapping.Component.buildType(Component.java:152)
at org.hibernate.mapping.Component.getType(Component.java:145)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
at org.hibernate.mapping.RootClass.validate(RootClass.java:193)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1108)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1293)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:855)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:774)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1460)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1398)
... 21 more
表定義。
CREATE TABLE gestionticket.tacheticket (
idTachet INT NOT NULL, idTicket INT NOT NULL,
PRIMARY KEY (idTachet, idTicket), INDEX idTicket_idx (idTicket ASC),
CONSTRAINT idTache FOREIGN KEY (idTachet) REFERENCES gestionticket.tache (idTache) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT idTicket FOREIGN KEY (idTicket) REFERENCES gestionticket.ticket (idTicket) ON DELETE NO ACTION ON UPDATE NO ACTION);
可以提供表結構,即字段名和類型 – bitkot
@AmitChotaliya表結構:CREATE TABLE'gestionticket'.'tacheticket'( 'idTachet' INT NOT NULL, 'idTicket' INT NOT NULL, PRIMARY KEY ('idTachet','idTicket') INDEX'idTicket_idx'('idTicket' ASC), 約束'idTache' 外鍵('idTachet') 參考'gestionticket'.'tache'('idTache') ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT'idTicket' FOREIGN KEY('idTicket') REFERENCES'gestionticket'.'tic ('idTicket') ON DELETE NO ACTION ON UPDATE NO ACTION); – user3850191
在你的問題,格式化,而不是在評論。 – philipxy