So. First i draw the database:
Code:
+----------+ +------------+
| Terms | | Codetable |
+----------+ +------------+
| Term_id | | Table |
| Lang | | Code |
| Descr | | Term_id |
+----------+ +------------+
because the first try not worked, and nobody can help, i try to add a Id column (as integer) to terms, and modify the mapping and class:
Code:
public class Terms {
private int id;
private String lang;
private String term_id;
private String descr;
public Terms(){
}
public String getDescr() {
return descr;
}
public void setDescr(String descr) {
this.descr = descr;
}
public String getLang() {
return lang;
}
public void setLang(String lang) {
this.lang = lang;
}
public String getTerm_id() {
return term_id;
}
public void setTerm_id(String term_id) {
this.term_id = term_id;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
Mapping:
Code:
<?xml version="1.0" encoding="ISO-8859-2"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.ignis.db.lang">
<class name="Terms" table="Terms">
<id name="id" type="int" column="id"/>
<property name="Term_id" not-null="false"/>
</class>
</hibernate-mapping>
(the codetable still the same)
i run the test program and i became a error:
Code:
Exception in thread "main" java.lang.ClassCastException: java.lang.String
at org.hibernate.type.ComponentType.toLoggableString(ComponentType.java:329)
at org.hibernate.pretty.MessageHelper.collectionInfoString(MessageHelper.java:284)
at org.hibernate.engine.CollectionLoadContext.getLoadingCollection(CollectionLoadContext.java:141)
at org.hibernate.type.CollectionType.getCollection(CollectionType.java:488)
at org.hibernate.type.CollectionType.resolveKey(CollectionType.java:341)
at org.hibernate.type.CollectionType.resolve(CollectionType.java:335)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:47)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:41)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:177)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:799)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:792)
at org.ignis.book.BookTest.main(BookTest.java:40)
what's wrong?
thanx:
Ignis