I am trying to retrive a collection with the help of one-to-many mapping. But when I try t retrive it, it says, it cannot initialize collection.
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.exception.SQLGrammarException: could not initialize a collection: [Business.CDC.Cdc.cdcOrganizationList#1] org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:681) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574) javax.servlet.http.HttpServlet.service(HttpServlet.java:621) javax.servlet.http.HttpServlet.service(HttpServlet.java:722) root cause
org.hibernate.exception.SQLGrammarException: could not initialize a collection: [Business.CDC.Cdc.cdcOrganizationList#1] org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67) org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) org.hibernate.loader.Loader.loadCollection(Loader.java:2001) org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36) org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565) org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60) org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716) org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344) org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86) org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:163) SpringControllers.MultiFunctionController.handleRequestInternal(MultiFunctionController.java:64) org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153) org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574) javax.servlet.http.HttpServlet.service(HttpServlet.java:621) javax.servlet.http.HttpServlet.service(HttpServlet.java:722) root cause
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'cdcorganiz0_.Cdc_Id' in 'field list' sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) java.lang.reflect.Constructor.newInstance(Constructor.java:513) com.mysql.jdbc.Util.handleNewInstance(Util.java:411) com.mysql.jdbc.Util.getInstance(Util.java:386) com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052) com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3609) com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541) com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2002) com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2163) com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2624) com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2127) com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2293) org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186) org.hibernate.loader.Loader.getResultSet(Loader.java:1787) org.hibernate.loader.Loader.doQuery(Loader.java:674) org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236) org.hibernate.loader.Loader.loadCollection(Loader.java:1994) org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36) org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565) org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60) org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716) org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344) org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86) org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:163) SpringControllers.MultiFunctionController.handleRequestInternal(MultiFunctionController.java:64) org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153) org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574) javax.servlet.http.HttpServlet.service(HttpServlet.java:621) javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
Here is My mapping file: -
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="Business.CDC.Cdc" table="CDC"> <id name="id" column="Cdc_Id"> <generator class="assigned"/> </id> <property name="name" column="Name" type="string"/> <property name="streetAddress" column="Street_Address" type="string"/> <property name="city" column="City" type="string"/> <property name="stateName" column="State_Name" type="string"/> <property name="zipCode" column="Zipcode" type="string"/> <set name="staffList" cascade="all"> <key column="Cdc_Id"/> <one-to-many class="Business.CDC.CdcStaff"/> </set> <set name="cdcOrganizationList" cascade="all"> <key column="Cdc_Id"/> <one-to-many class="Business.CDC.CdcOrganization"/> </set> <set name="phdList" cascade="all"> <key column="Cdc_Id"/> <one-to-many class="Business.PHD.Phd"/> </set> <set name="userAccountList" cascade="all"> <key column="Cdc_Id"/> <one-to-many class="Business.CDC.CdcUserAccount"/> </set> <set name="incomingList" cascade="all"> <key column="Cdc_Id"/> <one-to-many class="Business.CDC.CdcIncomingWorkRequest"/> </set> <set name="outgoingList" cascade="all"> <key column="Cdc_Id"/> <one-to-many class="Business.CDC.CdcOutgoingWorkRequest"/> </set> <set name="invoiceRequestList" cascade="all"> <key column="Cdc_Id"/> <one-to-many class="Business.CDC.CdcInvoicePaymentRequest"/> </set> </class> </hibernate-mapping>
|