describe:
i have four entity:person,autor,publication,work
person<-->author one2one
author<-->publication one2many
autthor<-->work many2many
version of Hibernate:2.1.1
error:
net.sf.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.many2many.Work
at net.sf.hibernate.id.Assigned.generate(Assigned.java:26)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:727)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:717)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1322)
at net.sf.hibernate.engine.Cascades$4.cascade(Cascades.java:114)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:436)
at net.sf.hibernate.engine.Cascades.cascadeCollection(Cascades.java:526)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:452)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:503)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:892)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:817)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:740)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:717)
at com.many2many.hibernateclienttest.main(hibernateclienttest.java:162)
source code:
person.java
package com.many2many;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class Person {
public Person() {
}
private String PersonID;
public void setPersonID(java.lang.String PersonID)
{
this.PersonID = PersonID;
}
public java.lang.String getPersonID()
{
return this.PersonID;
}
private java.lang.String NAME = null;
public void setNAME(java.lang.String NAME)
{
this.NAME = NAME;
}
public java.lang.String getNAME()
{
return this.NAME;
}
private java.lang.String EMAIL = null;
public void setEMAIL(java.lang.String EMAIL)
{
this.EMAIL = EMAIL;
}
public java.lang.String getEMAIL()
{
return this.EMAIL;
}
}
person.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.many2many.Person" table="DB_PERSON">
<id name="PersonID" type="java.lang.String" unsaved-value="any">
<column name="DB_PERSONID" sql-type="VARCHAR(911)" not-null="true"
length="41"/>
<generator class="assigned"/>
</id>
<property name="NAME" type="java.lang.String" update="true" insert="true">
<column name="DB_NAME" sql-type="VARCHAR(922)" length="400"
not-null="true"/>
</property>
<property name="EMAIL" type="java.lang.String" update="true" insert="true">
<column name="DB_EMAIL" sql-type="VARCHAR(933)" length="512"
not-null="true"/>
</property>
</class>
</hibernate-mapping>
author.java
package com.many2many;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class Author {
public Author() {
}
private java.lang.String AUTHORID;
public void setAUTHORID(java.lang.String AUTHORID)
{
this.AUTHORID = AUTHORID;
}
public java.lang.String getAUTHORID()
{
return this.AUTHORID;
}
private java.lang.String ALIAS = null;
public void setALIAS(java.lang.String ALIAS)
{
this.ALIAS = ALIAS;
}
public java.lang.String getALIAS()
{
return this.ALIAS;
}
private com.many2many.Person objPerson = null;
public void setobjPerson(com.many2many.Person objPerson)
{
this.objPerson = objPerson;
}
public com.many2many.Person getobjPerson()
{
return this.objPerson;
}
private java.util.Set publications = new java.util.HashSet();
public void setpublications(java.util.Set publications)
{
this.publications = publications;
}
public java.util.Set getpublications()
{
return this.publications;
}
public void addpublications(com.many2many.Publication objPublication)
{
this.publications.add(objPublication);
}
private java.util.Set works = new java.util.HashSet();
public void setworks(java.util.Set works)
{
this.works = works;
}
public java.util.Set getworks()
{
return this.works;
}
}
author.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.many2many.Author" table="DB_AUTHOR">
<id name="AUTHORID" type="java.lang.String" unsaved-value="any">
<column name="DB_AUTHORID" sql-type="VARCHAR2(911)" not-null="true"/>
<generator class="foreign">
<param name="property">objPerson</param>
</generator>
</id>
<property name="ALIAS" type="java.lang.String" update="true" insert="true">
<column name="DB_ALIAS" sql-type="VARCHAR2(922)" length="400"
not-null="false"/>
</property>
<one-to-one name="objPerson" class="com.many2many.Person" cascade="all" constrained="true"
outer-join="auto" access="property"/>
<set table="DB_PUBLICATION" name="publications" lazy="true" inverse="true" cascade="all" sort="unsorted">
<key column="DB_AUTHORID"/>
<one-to-many class="com.many2many.Publication"/>
</set>
<set table="DB_WORK" name="works" lazy="true" inverse="true" cascade="all" sort="unsorted">
<key column="DB_AUTHORID"/>
<many-to-many class="com.many2many.Work" column="DB_WORKID" outer-join="auto"/>
</set>
</class>
</hibernate-mapping>
publication.java
package com.many2many;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class Publication {
public Publication() {
}
private String id = null;
public void setid(java.lang.String id)
{
this.id = id;
}
public java.lang.String getid()
{
return this.id;
}
private String bookName = null;
public void setbookName(java.lang.String bookName)
{
this.bookName = bookName;
}
public java.lang.String getbookName()
{
return this.bookName;
}
private String dateTime = null;
public void setdateTime(java.lang.String dateTime)
{
this.dateTime = dateTime;
}
public java.lang.String getdateTime()
{
return this.dateTime;
}
private String authorId = null;
public void setauthorId(java.lang.String authorId)
{
this.authorId = authorId;
}
public java.lang.String getauthorId()
{
return this.authorId;
}
private com.many2many.Author objAuthor = null;
public void setobjAuthor(com.many2many.Author objAuthor)
{
this.objAuthor = objAuthor;
}
public com.many2many.Author getobjAuthor()
{
return this.objAuthor;
}
}
publication.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.many2many.Publication" table="DB_PUBLICATION">
<id name="id" type="java.lang.String" unsaved-value="any">
<column name="DB_PUBLICATIONID" sql-type="VARCHAR2(911)" not-null="true"
length="40"/>
<generator class="assigned"/>
</id>
<property name="bookName" type="java.lang.String" update="true" insert="true">
<column name="DB_BOOKNAME" sql-type="VARCHAR2(922)" length="400"
not-null="false"/>
</property>
<property name="dateTime" type="java.lang.String" update="true" insert="true">
<column name="DB_DATETIME" sql-type="VARCHAR2(933)" length="400"
not-null="false"/>
</property>
<many-to-one name="objAuthor" class="com.many2many.Publication" cascade="all"
column="DB_AUTHORID" not-null="false" update="true" insert="false"
outer-join="auto"/>
</class>
</hibernate-mapping>
work.java
package com.many2many;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class Work {
public Work() {
}
//
private String WorkID = null;
public void setWorkID(java.lang.String WorkID)
{
this.WorkID = WorkID;
}
public java.lang.String getWorkID()
{
return this.WorkID;
}
//
private String title = null;
public void settitle(java.lang.String title)
{
this.title = title;
}
public java.lang.String gettitle()
{
return this.title;
}
//
private java.util.Set authors = new java.util.HashSet();
public void setauthors(java.util.Set objauthors)
{
this.authors = objauthors;
}
public java.util.Set getauthors()
{
return this.authors;
}
}
work.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.many2many.Work" table="DB_WORK">
<id name="WorkID" type="java.lang.String" unsaved-value="any">
<column name="DB_WORKID" sql-type="VARCHAR2(911)" not-null="true"
length="40"/>
<generator class="assigned"/>
</id>
<property name="title" type="java.lang.String" update="true" insert="true">
<column name="DB_TITLE" sql-type="VARCHAR2(933)" length="400"
not-null="false"/>
</property>
<set table="DB_AUTHOR" name="authors" lazy="true" inverse="true" cascade="all" sort="unsorted">
<key column="DB_WORKID"/>
<many-to-many class="com.many2many.Author" column="DB_AUTHORID" outer-join="auto"/>
</set>
</class>
</hibernate-mapping>
the code of client is :
package com.many2many;
import net.sf.hibernate.Session;
import net.sf.hibernate.SessionFactory;
import net.sf.hibernate.Transaction;
import net.sf.hibernate.cfg.Configuration;
import net.sf.hibernate.tool.hbm2ddl.SchemaExport;
import net.sf.hibernate.MappingException;
import net.sf.hibernate.HibernateException;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class hibernateclienttest {
public hibernateclienttest() {
}
private static net.sf.hibernate.Transaction tx;
private static net.sf.hibernate.Session objSession;
public static void main(String [] agrs) throws Exception
{
try
{
Configuration objConfig = new Configuration();
SessionFactory objSessionFactory = objConfig.configure().
buildSessionFactory();
SchemaExport objSchema = new SchemaExport(objConfig);
objSchema.setOutputFile("SaveThePeople.SQL");
objSchema.create(true, true);
//
net.sf.hibernate.Session objSession = objSessionFactory.openSession();
tx = objSession.beginTransaction();
com.many2many.Person objPerson1 = new com.many2many.Person();
objPerson1.setPersonID("Person1");
objPerson1.setNAME("1name");
objPerson1.setEMAIL("1@163.com");
com.many2many.Person objPerson2 = new com.many2many.Person();
objPerson2.setPersonID("Person2");
objPerson2.setNAME("2name");
objPerson2.setEMAIL("2@163.com");
com.many2many.Person objPerson3 = new com.many2many.Person();
objPerson3.setPersonID("Person3");
objPerson3.setNAME("3name");
objPerson3.setEMAIL("3@163.com");
com.many2many.Person objPerson4 = new com.many2many.Person();
objPerson4.setPersonID("Person4");
objPerson4.setNAME("4name");
objPerson4.setEMAIL("4@163.com");
//objSession.save(objPerson1);
//objSession.save(objPerson2);
//objSession.save(objPerson3);
com.many2many.Publication objPublication1 = new com.many2many.Publication();
objPublication1.setid("publication1");
objPublication1.setbookName("english book");
objPublication1.setdateTime("20031010");
com.many2many.Publication objPublication2 = new com.many2many.Publication();
objPublication2.setid("publication2");
objPublication2.setbookName("japan");
objPublication2.setdateTime("19991011");
com.many2many.Publication objPublication3 = new com.many2many.Publication();
objPublication3.setid("publication3");
objPublication3.setbookName("program");
objPublication3.setdateTime("20040107");
com.many2many.Author objAuthor1 = new com.many2many.Author();
objAuthor1.setALIAS("1alias//★
objAuthor1.setobjPerson(objPerson1); //●
objAuthor1.addpublications(objPublication1); objAuthor1.addpublications(objPublication2); objAuthor1.addpublications(objPublication3);
objPublication1.setobjAuthor(objAuthor1);
objPublication2.setobjAuthor(objAuthor1);
objPublication3.setobjAuthor(objAuthor1);
com.many2many.Author objAuthor2 = new com.many2many.Author();
objAuthor2.setALIAS("2alias");
objAuthor2.setobjPerson(objPerson2);
com.many2many.Author objAuthor3 = new com.many2many.Author();
objAuthor3.setALIAS("2alias");
objAuthor3.setobjPerson(objPerson3);
com.many2many.Work objWork1 = new com.many2many.Work();
objWork1.setWorkID("work1");
objWork1.settitle("1title");
com.many2many.Work objWork2 = new com.many2many.Work();
objWork1.setWorkID("work2");
objWork2.settitle("2title");
com.many2many.Work objWork3 = new com.many2many.Work();
objWork1.setWorkID("work3");
objWork3.settitle("3title");
com.many2many.Work objWork4 = new com.many2many.Work();
objWork1.setWorkID("work4");
objWork4.settitle("4title");
objWork1.getauthors().add(objAuthor1);
objWork2.getauthors().add(objAuthor1);
objWork2.getauthors().add(objAuthor2);
objWork3.getauthors().add(objAuthor1);
objWork3.getauthors().add(objAuthor2);
objWork3.getauthors().add(objAuthor3);
objWork4.getauthors().add(objAuthor1);
objWork4.getauthors().add(objAuthor2);
objWork4.getauthors().add(objAuthor3);
objAuthor1.getworks().add(objWork1);
objAuthor1.getworks().add(objWork2);
objAuthor1.getworks().add(objWork3);
objAuthor1.getworks().add(objWork4);
objAuthor2.getworks().add(objWork2);
objAuthor2.getworks().add(objWork3);
objAuthor2.getworks().add(objWork4);
objAuthor3.getworks().add(objWork3);
objAuthor3.getworks().add(objWork4);
objSession.save(objAuthor1);
objSession.save(objAuthor2);
objSession.save(objAuthor3);
objSession.save(objWork1);
objSession.save(objWork2);
objSession.save(objWork3);
objSession.save(objWork4);
tx.commit();
return;
}
catch(MappingException me)
{
me.printStackTrace();
if(objSession!=null)
{
tx.rollback();
}
}
catch(HibernateException he)
{
he.printStackTrace();
if(objSession!=null)
{
tx.rollback();
}
}
finally
{
objSession.close();
}
}
}
the whole error code in the jbuilder9:
E:\JBuilder9\jdk1.4\bin\javaw -classpath "F:\ElsaJava\CodeHibernate\hibernate\classes;F:\ElsaJava\database\hibernate2.1.1\lib\ant.jar;F:\ElsaJava\database\hibernate2.1.1\lib\c3p0.jar;F:\ElsaJava\database\hibernate2.1.1\lib\cglib2.jar;F:\ElsaJava\database\hibernate2.1.1\lib\commons-collections.jar;F:\ElsaJava\database\hibernate2.1.1\lib\commons-dbcp.jar;F:\ElsaJava\database\hibernate2.1.1\lib\commons-lang.jar;F:\ElsaJava\database\hibernate2.1.1\lib\commons-logging.jar;F:\ElsaJava\database\hibernate2.1.1\lib\commons-pool.jar;F:\ElsaJava\database\hibernate2.1.1\lib\concurrent.jar;F:\ElsaJava\database\hibernate2.1.1\lib\connector.jar;F:\ElsaJava\database\hibernate2.1.1\lib\dom4j.jar;F:\ElsaJava\database\hibernate2.1.1\lib\ehcache.jar;F:\ElsaJava\database\hibernate2.1.1\lib\jaas.jar;F:\ElsaJava\database\hibernate2.1.1\lib\jboss-cache.jar;F:\ElsaJava\database\hibernate2.1.1\lib\jboss-common.jar;F:\ElsaJava\database\hibernate2.1.1\lib\jboss-jmx.jar;F:\ElsaJava\database\hibernate2.1.1\lib\jboss-system.jar;F:\ElsaJava\database\hibernate2.1.1\lib\jcs.jar;F:\ElsaJava\database\hibernate2.1.1\lib\jdbc2_0-stdext.jar;F:\ElsaJava\database\hibernate2.1.1\lib\jgroups.jar;F:\ElsaJava\database\hibernate2.1.1\lib\jta.jar;F:\ElsaJava\database\hibernate2.1.1\lib\junit.jar;F:\ElsaJava\database\hibernate2.1.1\lib\log4j.jar;F:\ElsaJava\database\hibernate2.1.1\lib\odmg.jar;F:\ElsaJava\database\hibernate2.1.1\lib\optional.jar;F:\ElsaJava\database\hibernate2.1.1\lib\oscache.jar;F:\ElsaJava\database\hibernate2.1.1\lib\proxool.jar;F:\ElsaJava\database\hibernate2.1.1\lib\swarmcache.jar;F:\ElsaJava\database\hibernate2.1.1\lib\xalan.jar;F:\ElsaJava\database\hibernate2.1.1\lib\xerces.jar;F:\ElsaJava\database\hibernate2.1.1\lib\xml-apis.jar;F:\ElsaJava\database\hibernate2.1.1\hibernate2.jar;E:\oracle\ora81\jdbc\lib\classes12.jar;E:\JBuilder9\thirdparty\junit3.8\junit.jar;E:\JBuilder9\lib\unittest.jar;E:\JBuilder9\jdk1.4\lib\dt.jar;E:\JBuilder9\jdk1.4\lib\htmlconverter.jar;E:\JBuilder9\jdk1.4\lib\tools.jar;E:\JBuilder9\jdk1.4\jre\lib\charsets.jar;E:\JBuilder9\jdk1.4\jre\lib\jaws.jar;E:\JBuilder9\jdk1.4\jre\lib\jce.jar;E:\JBuilder9\jdk1.4\jre\lib\jsse.jar;E:\JBuilder9\jdk1.4\jre\lib\rt.jar;E:\JBuilder9\jdk1.4\jre\lib\sunrsasign.jar;E:\JBuilder9\jdk1.4\jre\lib\im\indicim.jar;E:\JBuilder9\jdk1.4\jre\lib\ext\dnsns.jar;E:\JBuilder9\jdk1.4\jre\lib\ext\ldapsec.jar;E:\JBuilder9\jdk1.4\jre\lib\ext\localedata.jar;E:\JBuilder9\jdk1.4\jre\lib\ext\sunjce_provider.jar;E:\JBuilder9\jdk1.4\demo\plugin\jfc\Java2D\Java2Demo.jar;E:\JBuilder9\jdk1.4\demo\jfc\Java2D\Java2Demo.jar" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=survival:1861,suspend=y com.many2many.hibernateclienttest
08:22:16,381 INFO Environment:432 - Hibernate 2.1.1
08:22:16,421 INFO Environment:466 - loaded properties from resource hibernate.properties: {hibernate.cglib.use_reflection_optimizer=true}
08:22:16,441 INFO Environment:481 - using CGLIB reflection optimizer
08:22:18,284 INFO Configuration:843 - configuring from resource: /hibernate.cfg.xml
08:22:18,284 INFO Configuration:815 - Configuration resource: /hibernate.cfg.xml
08:22:20,637 INFO Configuration:300 - Mapping resource: ./com/many2many/Person.hbm.xml
08:22:21,228 INFO Binder:225 - Mapping class: com.many2many.Person -> DB_PERSON
08:22:21,759 INFO Configuration:300 - Mapping resource: ./com/many2many/Author.hbm.xml
08:22:21,949 INFO Binder:225 - Mapping class: com.many2many.Author -> DB_AUTHOR
08:22:22,109 INFO Binder:534 - Mapping collection: com.many2many.Author.works -> DB_WORK
08:22:22,119 INFO Configuration:300 - Mapping resource: ./com/many2many/Publication.hbm.xml
08:22:22,300 INFO Binder:225 - Mapping class: com.many2many.Publication -> DB_PUBLICATION
08:22:22,310 INFO Configuration:300 - Mapping resource: ./com/many2many/Work.hbm.xml
08:22:22,510 INFO Binder:225 - Mapping class: com.many2many.Work -> DB_WORK
08:22:22,510 INFO Binder:534 - Mapping collection: com.many2many.Work.authors -> DB_AUTHOR
08:22:22,520 INFO Configuration:998 - Configured SessionFactory: null
08:22:22,520 INFO Configuration:584 - processing one-to-many association mappings
08:22:22,530 INFO Binder:1139 - Mapping collection: com.many2many.Author.publications -> DB_PUBLICATION
08:22:22,580 INFO Configuration:593 - processing one-to-one association property references
08:22:22,620 INFO Configuration:618 - processing foreign key constraints
08:22:22,840 INFO Dialect:82 - Using dialect: net.sf.hibernate.dialect.OracleDialect
08:22:22,850 INFO SettingsFactory:62 - Use outer join fetching: true
08:22:22,880 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
08:22:22,880 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 20
08:22:22,900 INFO DriverManagerConnectionProvider:71 - using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:oci8:@platform
08:22:22,910 INFO DriverManagerConnectionProvider:72 - connection properties: {user=hibernate, password=hibernate}
08:22:22,950 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
08:22:26,395 INFO SettingsFactory:89 - Use scrollable result sets: true
08:22:26,395 INFO SettingsFactory:90 - JDBC 2 max batch size: 15
08:22:26,405 INFO SettingsFactory:96 - echoing all SQL to stdout
08:22:26,405 INFO SettingsFactory:99 - Query language substitutions: {}
08:22:26,405 INFO SettingsFactory:110 - cache provider: net.sf.ehcache.hibernate.Provider
08:22:26,435 INFO Configuration:1057 - instantiating and configuring caches
08:22:27,096 INFO SessionFactoryImpl:119 - building session factory
08:22:29,069 INFO SessionFactoryObjectFactory:82 - no JNDI name configured
08:22:29,079 INFO Dialect:82 - Using dialect: net.sf.hibernate.dialect.OracleDialect
08:22:29,089 INFO Configuration:584 - processing one-to-many association mappings
08:22:29,089 INFO Configuration:593 - processing one-to-one association property references
08:22:29,089 INFO Configuration:618 - processing foreign key constraints
08:22:29,109 INFO Configuration:584 - processing one-to-many association mappings
08:22:29,109 INFO Configuration:593 - processing one-to-one association property references
08:22:29,109 INFO Configuration:618 - processing foreign key constraints
08:22:29,119 INFO SchemaExport:98 - Running hbm2ddl schema export
08:22:29,129 INFO SchemaExport:112 - writing generated schema to file: SaveThePeople.SQL
08:22:29,179 INFO SchemaExport:117 - exporting generated schema to database
08:22:29,189 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
08:22:29,189 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 20
08:22:29,189 INFO DriverManagerConnectionProvider:71 - using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:oci8:@platform
08:22:29,240 INFO DriverManagerConnectionProvider:72 - connection properties: {user=hibernate, password=hibernate}
alter table DB_AUTHOR drop constraint FK3F6B206C1124BE87
alter table DB_PUBLICATION drop constraint FK97ACCFCB1124BE87
drop table DB_AUTHOR cascade constraints
drop table DB_PUBLICATION cascade constraints
drop table DB_WORK cascade constraints
drop table DB_PERSON cascade constraints
create table DB_AUTHOR (
DB_AUTHORID VARCHAR2(911) not null,
DB_ALIAS VARCHAR2(922),
DB_WORKID VARCHAR2(255) not null,
primary key (DB_WORKID, DB_AUTHORID)
)
create table DB_PUBLICATION (
DB_PUBLICATIONID VARCHAR2(911) not null,
DB_BOOKNAME VARCHAR2(922),
DB_DATETIME VARCHAR2(933),
DB_AUTHORID VARCHAR2(40),
primary key (DB_PUBLICATIONID)
)
create table DB_WORK (
DB_WORKID VARCHAR2(911) not null,
DB_TITLE VARCHAR2(933),
DB_AUTHORID VARCHAR2(255) not null,
primary key (DB_AUTHORID, DB_WORKID)
)
create table DB_PERSON (
DB_PERSONID VARCHAR(911) not null,
DB_NAME VARCHAR(922) not null,
DB_EMAIL VARCHAR(933) not null,
primary key (DB_PERSONID)
)
alter table DB_AUTHOR add constraint FK3F6B206C1124BE87 foreign key (DB_AUTHORID) references DB_PERSON
alter table DB_PUBLICATION add constraint FK97ACCFCB1124BE87 foreign key (DB_AUTHORID) references DB_PUBLICATION
08:22:30,632 INFO SchemaExport:160 - schema export complete
08:22:30,642 INFO DriverManagerConnectionProvider:137 - cleaning up connection pool: jdbc:oracle:oci8:@platform
08:22:30,772 INFO DriverManagerConnectionProvider:137 - cleaning up connection pool: jdbc:oracle:oci8:@platform
net.sf.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.many2many.Work
at net.sf.hibernate.id.Assigned.generate(Assigned.java:26)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:727)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:717)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1322)
at net.sf.hibernate.engine.Cascades$4.cascade(Cascades.java:114)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:436)
at net.sf.hibernate.engine.Cascades.cascadeCollection(Cascades.java:526)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:452)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:503)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:892)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:817)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:740)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:717)
at com.many2many.hibernateclienttest.main(hibernateclienttest.java:162)
|