-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 
Author Message
 Post subject: Collection not being persisted to database ???
PostPosted: Tue Nov 28, 2006 1:19 pm 
Beginner
Beginner

Joined: Fri Oct 06, 2006 7:11 am
Posts: 32
Hi, I have the following relationship

Certificate has one or more Packers
Packer has one or more Manufacturers

When I create a Certificate and save it, everything works fine. When I create a Certificate and try to add a Packer nothing is saved. The SQL seems to be generated ok but nothing is generated for the Manufacturer Links table.

I am using a Servlet Filter to commit the transaction and close the session after any jsp's have been displayed.

I've tried removing references to the Manufacturer from the Packer.hbm.xml file but still I do not get anything saved. The only time the Certificate saves is when I do not add a Packer...

Any help is greatly appreciated

Paul


Hibernate version: 3

Name and version of the database you are using: Oracle 8i

The generated SQL (show_sql=true):
Code:
    insert
    into
        dpcs.DPCS_CERTIFICATE
        (APPLICATION_DATE, APPLICANT_ID, DATE_APPROVED, APPROVAL_NO, CERT_EXPIRE_DATE, CONSIGNOR, CONSIGNEE, CONTACT_DETAILS, ORIGIN_COUNTRY, CREATED_DATE, CREATED_BY, DISPATCH_DATE, DESTINATION, ISSUE_DATE, ISSUED_BY, TRANSPORT, OTHER, DISPATCH_LOCATION, PLANT_SOURCE_SVS, RECEIPT_DATE, COUNTRY_SOURCE_EXROI, STATUS, SUPPLEMENTARY_INFO, TRADER_REF, TYPE_OF_PACKAGING, CERTIFICATE_NUMBER, CERTIFICATE_ID)
    values
        (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

    insert
    into
        dpcs.DPCS_PACKER
        (APPROVAL_NUMBER, ADDRESS, BATCH_SERIAL_NO, GENERIC_PRODUCT_NAME, MANUFACTURER_IS_PACKER, MILK_SOURCE_ROI, NET_WEIGHT, NAME, PLANT_SOURCE_SVS, PRODUCTION_CODES, PRODUCT_DESCRIPTION, PRODUCT_EXPIRY_DATE, QUANTITY, SOURCE_NON_ROI_MILK, PACKAGING_TYPE, PACKER_ID)
    values
        (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

   insert
    into
        dpcs.DPCS_MANUFACTURER
        (APPROVAL_NUMBER, NAME, ADDRESS, MANUFACTURER_ID)
    values
        (?, ?, ?, ?)

    insert
    into
        dpcs.DPCS_CERTIFICATE_PACKER_LINKS
        (CERTIFICATE_ID, PACKER_ID)
    values
        (?, ?)


Mapping documents:

Certificate.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    <class name="ie.gov.agriculture.dpcs.cert.Certificate" table="DPCS_CERTIFICATE">
       <id name="certificateId" column="CERTIFICATE_ID" type="long" unsaved-value="0">
           <generator class="sequence">
              <param name="sequence">CERTIFICATE_ID_SEQ</param>
           </generator>
       </id>
      <property name="applicationDateTime" column="APPLICATION_DATE" type="string"/>
      <property name="applicantBusinessId" column="APPLICANT_ID" type="string"/>
      <property name="approvalDate" column="DATE_APPROVED" type="string"/>
      <property name="approvalNo" column="APPROVAL_NO" type="string"/>
      <property name="certExpiryDate" column="CERT_EXPIRE_DATE" type="string"/>
      <property name="consignor" column="CONSIGNOR" type="string"/>
      <property name="consignee" column="CONSIGNEE" type="string"/>
      <property name="contactDetails" column="CONTACT_DETAILS" type="string"/>
      <property name="countryOfOrigin" column="ORIGIN_COUNTRY" type="string"/>
      <property name="createdDate" column="CREATED_DATE" type="string"/>
      <property name="createdBy" column="CREATED_BY" type="string"/>
      <property name="dateOfDispatch" column="DISPATCH_DATE" type="string"/>
      <property name="destination" column="DESTINATION" type="string"/>
      <property name="issueDate" column="ISSUE_DATE" type="string"/>
      <property name="issuedBy" column="ISSUED_BY" type="string"/>
      <property name="meansOfTransport" column="TRANSPORT" type="string"/>
      <property name="other" column="OTHER" type="string"/>
      <property name="placeOfDispatch" column="DISPATCH_LOCATION" type="string"/>
      <property name="plantSourceForSvs" column="PLANT_SOURCE_SVS" type="string"/>
      <property name="receiptDateTime" column="RECEIPT_DATE" type="string"/>
      <property name="sourceCountryExRoi" column="COUNTRY_SOURCE_EXROI" type="string"/>
      <property name="status" column="STATUS" type="string"/>
      <property name="supplementaryInfo" column="SUPPLEMENTARY_INFO" type="string"/>
      <property name="traderRef" column="TRADER_REF" type="string"/>
      <property name="typeOfPackaging" column="TYPE_OF_PACKAGING" type="string"/>
      <property name="certificateNumber" column="CERTIFICATE_NUMBER" type="string"/>

      <set name="packers" table="DPCS_CERTIFICATE_PACKER_LINKS" cascade="save-update">
          <key column="CERTIFICATE_ID"/>
          <many-to-many column="PACKER_ID"
                     class="ie.gov.agriculture.dpcs.cert.Packer"/>
      </set>          
      
    </class>
</hibernate-mapping>



Packer.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    <class name="ie.gov.agriculture.dpcs.cert.Packer" table="DPCS_PACKER">
       <id name="packerId" column="PACKER_ID" type="long" unsaved-value="0">
           <generator class="sequence">
              <param name="sequence">PACKER_ID_SEQ</param>
           </generator>
       </id>

      <property name="approvalNumber" column="APPROVAL_NUMBER" type="string"/>
      <property name="address" column="ADDRESS" type="string"/>
      <property name="batchSerialNumber" column="BATCH_SERIAL_NO" type="string"/>
      <property name="genericProductName" column="GENERIC_PRODUCT_NAME" type="string"/>
      <property name="manufacturerSameAsPacker" column="MANUFACTURER_IS_PACKER" type="boolean"/>   
      <property name="milkRoi" column="MILK_SOURCE_ROI" type="boolean"/>   
      <property name="netWeight" column="NET_WEIGHT" type="string"/>
      <property name="name" column="NAME" type="string"/>
      <property name="plantSourceForSvs" column="PLANT_SOURCE_SVS" type="string"/>         
      <property name="productionCodes" column="PRODUCTION_CODES" type="string"/>
      <property name="productDescription" column="PRODUCT_DESCRIPTION" type="string"/>
      <property name="productExpiryDate" column="PRODUCT_EXPIRY_DATE" type="string"/>
      <property name="quantity" column="QUANTITY" type="string"/>
      <property name="sourceCountryExRoi" column="SOURCE_NON_ROI_MILK" type="string"/>
      <property name="typeOfPackaging" column="PACKAGING_TYPE" type="string"/>

      <set name="manufacturers" table="DPCS_PACKER_MANUFACTURER_LINKS" cascade="all">
          <key column="PACKER_ID"/>
          <many-to-many column="MANUFACTURER_ID"
                     class="ie.gov.agriculture.dpcs.cert.Manufacturer"/>
      </set>
    </class>
</hibernate-mapping>


Manufacturer.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    <class name="ie.gov.agriculture.dpcs.cert.Manufacturer" table="DPCS_MANUFACTURER">
       <id name="manufacturerId" column="MANUFACTURER_ID" type="long" unsaved-value="0">
           <generator class="sequence">
              <param name="sequence">MANUFACTURER_ID_SEQ</param>
           </generator>
       </id>

      <property name="approvalNumber" column="APPROVAL_NUMBER" type="string"/>
      <property name="name" column="NAME" type="string"/>
      <property name="address" column="ADDRESS" type="string"/>
    </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

Code:
Session session = HibernateUtil.getSession();
HibernateUtil.beginTransaction();      
certificate.setApplicationDateTime("29/11/2006");
Packer packer = new Packer();
packer.setName("Kerry Gold");
   
Manufacturer manuf = new Manufacturer();
manuf.setName("Kerry Golden");
packer.addManufacturer(manuf);
      
certificate.addPacker(packer);
session.save(certificate);


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 28, 2006 1:28 pm 
Senior
Senior

Joined: Mon Oct 23, 2006 5:12 am
Posts: 141
Location: Galicia, Spain
First things first: why are you using many-to-many instead of bidirectional parent-child associations (one-to-many & many-to-one)?

If you use bidirectional parent-child associations everyhing will go fine...

http://www.hibernate.org/hib_docs/v3/re ... tional-m21

_________________
andresgr (--don't forget to rate)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 5:38 am 
Beginner
Beginner

Joined: Fri Oct 06, 2006 7:11 am
Posts: 32
Thanks for the reply.

I am using a many-many unidirectional link as the Packer can exist by itself. Also, the Packer can be associated to more than one certificate and any certificate can have more than one packer.

It should be possible to use the many-many unidirectional association (see 7.3.4. many to many, from your link).

It's not necessarily a design question but I'm asking is there something wrong with my many-many association.

thanks
Paul


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 5:53 am 
Senior
Senior

Joined: Mon Oct 23, 2006 5:12 am
Posts: 141
Location: Galicia, Spain
Ok.

So the problem seems to be the transaction is not beeing comitted...

I suggest you to turn on logging (log4j) for hibernate and see if the transaction is being commited after doing those insert's...

_________________
andresgr (--don't forget to rate)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 11:53 am 
Beginner
Beginner

Joined: Fri Oct 06, 2006 7:11 am
Posts: 32
Hi,

I've turned on as many loggers as I can and have a some output here. The application seems to be hanging when I try to add a collection i.e a packer.

thanks again for any help
Paul


Code:
15:26:18,031 DEBUG HibernateUtil:57 - HibernateUtil::Opening new Hibernate Session
15:26:18,031 DEBUG HibernateUtil:59 - HibernateUtil::Added Session to current Thread
15:26:21,515 DEBUG HibernateUtil:104 - HibernateUtil::Starting new Hibernate Transaction
15:26:22,937 DEBUG JDBCTransaction:54 - begin
15:26:22,937 DEBUG ConnectionManager:415 - opening JDBC connection
15:26:22,937 DEBUG DriverManagerConnectionProvider:93 - total checked-out connections: 0
15:26:22,937 DEBUG DriverManagerConnectionProvider:99 - using pooled JDBC connection, pool size: 0
15:26:22,937 DEBUG JDBCContext:159 - no active transaction, could not register Synchronization
15:26:22,937 DEBUG JDBCTransaction:59 - current autocommit status: false
15:26:22,937 DEBUG JDBCContext:194 - after transaction begin
15:26:22,937 DEBUG HibernateUtil:108 - HibernateUtil::Added Hibernate Transaction to local thread:: tx is Active= true
15:26:22,953 DEBUG DefaultSaveOrUpdateEventListener:161 - saving transient instance
15:26:22,953 DEBUG AbstractBatcher:311 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
15:26:22,953 DEBUG SQL:346 -
    select
        dpcs.CERTIFICATE_ID_SEQ.nextval
    from
        dual
06/11/29 15:26:22 Hibernate:
    select
        dpcs.CERTIFICATE_ID_SEQ.nextval
    from
        dual
15:26:22,953 DEBUG AbstractBatcher:424 - preparing statement
15:26:22,968 DEBUG SequenceGenerator:82 - Sequence identifier generated: 282
15:26:22,968 DEBUG AbstractBatcher:319 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
15:26:22,968 DEBUG AbstractBatcher:470 - closing statement
15:26:22,968 DEBUG AbstractSaveEventListener:106 - generated identifier: 282, using strategy: org.hibernate.id.SequenceGenerator
15:26:22,968 DEBUG AbstractSaveEventListener:139 - saving [ie.gov.agriculture.dpcs.cert.Certificate#282]
15:26:22,968 DEBUG Cascade:237 - processing cascade ACTION_SAVE_UPDATE for: ie.gov.agriculture.dpcs.cert.Certificate
15:26:22,968 DEBUG Cascade:259 - done processing cascade ACTION_SAVE_UPDATE for: ie.gov.agriculture.dpcs.cert.Certificate
15:26:23,031 DEBUG WrapVisitor:87 - Wrapped collection in role: ie.gov.agriculture.dpcs.cert.Certificate.packers
15:26:23,046 DEBUG Cascade:237 - processing cascade ACTION_SAVE_UPDATE for: ie.gov.agriculture.dpcs.cert.Certificate
15:26:23,046 DEBUG Cascade:285 - cascade ACTION_SAVE_UPDATE for collection: ie.gov.agriculture.dpcs.cert.Certificate.packers
15:26:23,046 DEBUG CascadingAction:133 - cascading to saveOrUpdate: ie.gov.agriculture.dpcs.cert.Packer
15:26:23,046 DEBUG IdentifierValue:104 - id unsaved-value: 0
15:26:23,062 DEBUG AbstractSaveEventListener:462 - transient instance of: ie.gov.agriculture.dpcs.cert.Packer
15:26:23,062 DEBUG DefaultSaveOrUpdateEventListener:161 - saving transient instance
15:26:23,062 DEBUG AbstractBatcher:311 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
15:26:23,062 DEBUG SQL:346 -
    select
        dpcs.PACKER_ID_SEQ.nextval
    from
        dual
06/11/29 15:26:23 Hibernate:
    select
        dpcs.PACKER_ID_SEQ.nextval
    from
        dual
15:26:23,078 DEBUG AbstractBatcher:424 - preparing statement
15:26:23,078 DEBUG SequenceGenerator:82 - Sequence identifier generated: 141
15:26:23,078 DEBUG AbstractBatcher:319 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
15:26:23,078 DEBUG AbstractBatcher:470 - closing statement
15:26:23,078 DEBUG AbstractSaveEventListener:106 - generated identifier: 141, using strategy: org.hibernate.id.SequenceGenerator
15:26:23,078 DEBUG AbstractSaveEventListener:139 - saving [ie.gov.agriculture.dpcs.cert.Packer#141]
15:26:23,078 DEBUG Cascade:300 - done cascade ACTION_SAVE_UPDATE for collection: ie.gov.agriculture.dpcs.cert.Certificate.packers
15:26:23,078 DEBUG Cascade:259 - done processing cascade ACTION_SAVE_UPDATE for: ie.gov.agriculture.dpcs.cert.Certificate
15:26:23,078 DEBUG CreateCertStep2:104 - Created certificate with ID=282
15:26:23,078 DEBUG CreateCertStep2:114 - Creating Exporter Certificate: Step 2
15:26:23,078 DEBUG BaseAction:85 - Returning action forward: ForwardConfig[name=Success,path=/CreateCertTile.jsp,redirect=false,contextRelative=false,module=null]
15:26:29,703 DEBUG HibernateUtil:131 - HibernateUtil::Commiting Hibernate Transaction
15:26:35,390 DEBUG JDBCTransaction:103 - commit
15:26:39,593 DEBUG SessionImpl:332 - automatically flushing session
15:26:39,593 DEBUG AbstractFlushingEventListener:58 - flushing session
15:26:39,593 DEBUG AbstractFlushingEventListener:111 - processing flush-time cascades
15:26:39,593 DEBUG Cascade:237 - processing cascade ACTION_SAVE_UPDATE for: ie.gov.agriculture.dpcs.cert.Certificate
15:26:39,609 DEBUG Cascade:285 - cascade ACTION_SAVE_UPDATE for collection: ie.gov.agriculture.dpcs.cert.Certificate.packers
15:26:39,609 DEBUG CascadingAction:133 - cascading to saveOrUpdate: ie.gov.agriculture.dpcs.cert.Packer
15:26:39,609 DEBUG AbstractSaveEventListener:436 - persistent instance of: ie.gov.agriculture.dpcs.cert.Packer
15:26:39,609 DEBUG DefaultSaveOrUpdateEventListener:105 - ignoring persistent instance
15:26:39,624 DEBUG DefaultSaveOrUpdateEventListener:142 - object already associated with session: [ie.gov.agriculture.dpcs.cert.Packer#141]
15:26:39,624 DEBUG Cascade:300 - done cascade ACTION_SAVE_UPDATE for collection: ie.gov.agriculture.dpcs.cert.Certificate.packers
15:26:39,624 DEBUG Cascade:259 - done processing cascade ACTION_SAVE_UPDATE for: ie.gov.agriculture.dpcs.cert.Certificate
15:26:39,624 DEBUG AbstractFlushingEventListener:153 - dirty checking collections
15:26:39,640 DEBUG AbstractFlushingEventListener:170 - Flushing entities and processing referenced collections
15:26:39,656 DEBUG Collections:176 - Collection found: [ie.gov.agriculture.dpcs.cert.Certificate.packers#282], was: [<unreferenced>] (initialized)
15:26:39,656 DEBUG AbstractFlushingEventListener:209 - Processing unreferenced collections
15:26:39,671 DEBUG AbstractFlushingEventListener:223 - Scheduling collection removes/(re)creates/updates
15:26:39,687 DEBUG AbstractFlushingEventListener:85 - Flushed: 2 insertions, 0 updates, 0 deletions to 2 objects
15:26:39,687 DEBUG AbstractFlushingEventListener:91 - Flushed: 1 (re)creations, 0 updates, 0 removals to 1 collections
15:26:39,687 DEBUG Printer:83 - listing entities:
15:26:39,687 DEBUG Printer:90 - ie.gov.agriculture.dpcs.cert.Certificate{createdDate=null, issuedBy=null, certExpiryDate=null, contactDetails=, applicantBusinessId=null, plantSourceForSvs=null, approvalNo=null, applicationDateTime=29-11-2006 15:26:22, certificateNumber=null, sourceCountryExRoi=null, consignee=, consignor=, approvalDate=null, supplementaryInfo=null, other=null, destination=1, meansOfTransport=, receiptDateTime=null, dateOfDispatch=, issueDate=null, createdBy=null, placeOfDispatch=, status=null, traderRef=, countryOfOrigin=1, packers=[ie.gov.agriculture.dpcs.cert.Packer#141], typeOfPackaging=null, certificateId=282}
15:26:39,703 DEBUG Printer:90 - ie.gov.agriculture.dpcs.cert.Packer{milkRoi=false, productExpiryDate=null, genericProductName=null, packerId=141, address=null, plantSourceForSvs=null, productDescription=null, productionCodes=null, batchSerialNumber=null, approvalNumber=29-11-2006 15:26:22, manufacturerSameAsPacker=false, sourceCountryExRoi=null, netWeight=null, typeOfPackaging=null, quantity=null, name=Kerry Gold}
15:26:39,703 DEBUG AbstractFlushingEventListener:289 - executing flush
15:26:39,703 DEBUG ConnectionManager:463 - registering flush begin
15:26:39,734 DEBUG AbstractEntityPersister:2034 - Inserting entity: [ie.gov.agriculture.dpcs.cert.Certificate#282]
15:26:55,265 DEBUG AbstractBatcher:311 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
15:27:06,156 DEBUG SQL:346 -
    insert
    into
        dpcs.DPCS_CERTIFICATE
        (APPLICATION_DATE, APPLICANT_ID, DATE_APPROVED, APPROVAL_NO, CERT_EXPIRE_DATE, CONSIGNOR, CONSIGNEE, CONTACT_DETAILS, ORIGIN_COUNTRY, CREATED_DATE, CREATED_BY, DISPATCH_DATE, DESTINATION, ISSUE_DATE, ISSUED_BY, TRANSPORT, OTHER, DISPATCH_LOCATION, PLANT_SOURCE_SVS, RECEIPT_DATE, COUNTRY_SOURCE_EXROI, STATUS, SUPPLEMENTARY_INFO, TRADER_REF, TYPE_OF_PACKAGING, CERTIFICATE_NUMBER, CERTIFICATE_ID)
    values
        (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
06/11/29 15:27:06 Hibernate:
    insert
    into
        dpcs.DPCS_CERTIFICATE
        (APPLICATION_DATE, APPLICANT_ID, DATE_APPROVED, APPROVAL_NO, CERT_EXPIRE_DATE, CONSIGNOR, CONSIGNEE, CONTACT_DETAILS, ORIGIN_COUNTRY, CREATED_DATE, CREATED_BY, DISPATCH_DATE, DESTINATION, ISSUE_DATE, ISSUED_BY, TRANSPORT, OTHER, DISPATCH_LOCATION, PLANT_SOURCE_SVS, RECEIPT_DATE, COUNTRY_SOURCE_EXROI, STATUS, SUPPLEMENTARY_INFO, TRADER_REF, TYPE_OF_PACKAGING, CERTIFICATE_NUMBER, CERTIFICATE_ID)
    values
        (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
15:27:06,171 DEBUG AbstractBatcher:424 - preparing statement
15:27:34,812 DEBUG AbstractEntityPersister:1821 - Dehydrating entity: [ie.gov.agriculture.dpcs.cert.Certificate#282]
15:27:34,812 DEBUG StringType:80 - binding '29-11-2006 15:26:22' to parameter: 1
15:27:34,812 DEBUG StringType:73 - binding null to parameter: 2
15:27:34,812 DEBUG StringType:73 - binding null to parameter: 3
15:27:34,828 DEBUG StringType:73 - binding null to parameter: 4
15:27:34,828 DEBUG StringType:73 - binding null to parameter: 5
15:27:34,828 DEBUG StringType:80 - binding '' to parameter: 6
15:27:34,828 DEBUG StringType:80 - binding '' to parameter: 7
15:27:34,843 DEBUG StringType:80 - binding '' to parameter: 8
15:27:34,843 DEBUG StringType:80 - binding '1' to parameter: 9
15:27:34,843 DEBUG StringType:73 - binding null to parameter: 10
15:27:34,843 DEBUG StringType:73 - binding null to parameter: 11
15:27:34,859 DEBUG StringType:80 - binding '' to parameter: 12
15:27:34,859 DEBUG StringType:80 - binding '1' to parameter: 13
15:27:34,859 DEBUG StringType:73 - binding null to parameter: 14
15:27:34,874 DEBUG StringType:73 - binding null to parameter: 15
15:27:34,874 DEBUG StringType:80 - binding '' to parameter: 16
15:27:34,890 DEBUG StringType:73 - binding null to parameter: 17
15:27:34,890 DEBUG StringType:80 - binding '' to parameter: 18
15:27:34,890 DEBUG StringType:73 - binding null to parameter: 19
15:27:34,890 DEBUG StringType:73 - binding null to parameter: 20
15:27:34,906 DEBUG StringType:73 - binding null to parameter: 21
15:27:34,906 DEBUG StringType:73 - binding null to parameter: 22
15:27:34,906 DEBUG StringType:73 - binding null to parameter: 23
15:27:34,906 DEBUG StringType:80 - binding '' to parameter: 24
15:27:34,921 DEBUG StringType:73 - binding null to parameter: 25
15:27:34,921 DEBUG StringType:73 - binding null to parameter: 26
15:27:34,921 DEBUG LongType:80 - binding '282' to parameter: 27
15:27:42,609 DEBUG AbstractBatcher:28 - Adding to batch
15:28:03,749 DEBUG AbstractEntityPersister:2034 - Inserting entity: [ie.gov.agriculture.dpcs.cert.Packer#141]
15:28:14,437 DEBUG AbstractBatcher:55 - Executing batch size: 1
15:28:14,484 DEBUG AbstractBatcher:85 - success of batch update unknown: 0
15:28:14,484 DEBUG AbstractBatcher:319 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
15:28:14,484 DEBUG AbstractBatcher:470 - closing statement
15:28:15,171 DEBUG AbstractBatcher:311 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
15:28:15,999 DEBUG SQL:346 -
    insert
    into
        dpcs.DPCS_PACKER
        (APPROVAL_NUMBER, ADDRESS, BATCH_SERIAL_NO, GENERIC_PRODUCT_NAME, MANUFACTURER_IS_PACKER, MILK_SOURCE_ROI, NET_WEIGHT, NAME, PLANT_SOURCE_SVS, PRODUCTION_CODES, PRODUCT_DESCRIPTION, PRODUCT_EXPIRY_DATE, QUANTITY, SOURCE_NON_ROI_MILK, PACKAGING_TYPE, PACKER_ID)
    values
        (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
06/11/29 15:28:16 Hibernate:
    insert
    into
        dpcs.DPCS_PACKER
        (APPROVAL_NUMBER, ADDRESS, BATCH_SERIAL_NO, GENERIC_PRODUCT_NAME, MANUFACTURER_IS_PACKER, MILK_SOURCE_ROI, NET_WEIGHT, NAME, PLANT_SOURCE_SVS, PRODUCTION_CODES, PRODUCT_DESCRIPTION, PRODUCT_EXPIRY_DATE, QUANTITY, SOURCE_NON_ROI_MILK, PACKAGING_TYPE, PACKER_ID)
    values
        (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
15:28:16,015 DEBUG AbstractBatcher:424 - preparing statement
15:28:40,624 DEBUG AbstractEntityPersister:1821 - Dehydrating entity: [ie.gov.agriculture.dpcs.cert.Packer#141]
15:28:40,624 DEBUG StringType:80 - binding '29-11-2006 15:26:22' to parameter: 1
15:28:40,640 DEBUG StringType:73 - binding null to parameter: 2
15:28:40,640 DEBUG StringType:73 - binding null to parameter: 3
15:28:40,656 DEBUG StringType:73 - binding null to parameter: 4
15:28:40,656 DEBUG BooleanType:80 - binding 'false' to parameter: 5
15:28:40,656 DEBUG BooleanType:80 - binding 'false' to parameter: 6
15:28:40,656 DEBUG StringType:73 - binding null to parameter: 7
15:28:40,671 DEBUG StringType:80 - binding 'Kerry Gold' to parameter: 8
15:28:40,671 DEBUG StringType:73 - binding null to parameter: 9
15:28:40,671 DEBUG StringType:73 - binding null to parameter: 10
15:28:40,671 DEBUG StringType:73 - binding null to parameter: 11
15:28:40,687 DEBUG StringType:73 - binding null to parameter: 12
15:28:40,687 DEBUG StringType:73 - binding null to parameter: 13
15:28:40,687 DEBUG StringType:73 - binding null to parameter: 14
15:28:40,687 DEBUG StringType:73 - binding null to parameter: 15
15:28:40,703 DEBUG LongType:80 - binding '141' to parameter: 16
15:28:43,031 DEBUG AbstractBatcher:28 - Adding to batch
15:30:55,062 DEBUG AbstractBatcher:55 - Executing batch size: 1
15:32:21,859 DEBUG AbstractBatcher:85 - success of batch update unknown: 0
15:32:39,515 DEBUG AbstractBatcher:319 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
15:32:41,609 DEBUG AbstractBatcher:470 - closing statement
15:33:34,687 DEBUG AbstractCollectionPersister:999 - Inserting collection: [ie.gov.agriculture.dpcs.cert.Certificate.packers#282]
15:34:49,609 DEBUG AbstractBatcher:311 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
15:35:05,531 DEBUG SQL:346 -
    insert
    into
        dpcs.DPCS_CERTIFICATE_PACKER_LINKS
        (CERTIFICATE_ID, PACKER_ID)
    values
        (?, ?)
06/11/29 15:35:05 Hibernate:
    insert
    into
        dpcs.DPCS_CERTIFICATE_PACKER_LINKS
        (CERTIFICATE_ID, PACKER_ID)
    values
        (?, ?)
15:35:05,531 DEBUG AbstractBatcher:424 - preparing statement
15:35:38,843 DEBUG LongType:80 - binding '282' to parameter: 1
15:36:06,468 DEBUG LongType:80 - binding '141' to parameter: 2
15:36:13,187 DEBUG AbstractBatcher:28 - Adding to batch
15:36:31,171 DEBUG AbstractCollectionPersister:1045 - done inserting collection: 1 rows inserted
15:40:10,124 DEBUG AbstractBatcher:55 - Executing batch size: 1


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 12:02 pm 
Senior
Senior

Joined: Mon Oct 23, 2006 5:12 am
Posts: 141
Location: Galicia, Spain
Please, post your POJOs definitions (entirely).

_________________
andresgr (--don't forget to rate)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 12:27 pm 
Beginner
Beginner

Joined: Fri Oct 06, 2006 7:11 am
Posts: 32
POJO's are below.

I can save a Certificate but can't add a Packer to it and save both.

thanks
Paul


Certificate
Code:
package ie.gov.agriculture.dpcs.cert;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;

public class Certificate implements Serializable{

   /**
    *
    */
   private static final long serialVersionUID = 1L;

    /**
     * The unique Certificate Id
     */
    private long certificateId = 0L;

   /**
    * The cert type used for this Certificate
    */
   private CertType certType = null;
      
   /**
    * Set of statements associated with this Certificate. This will only
    * be populated when the Certificate is a Variable Certificate and the user
    * may have selected a subset of Statements available in the CertType.
    * The CertType contains the full set of statements that were added when it
    * was created, we cannot modify that, therefore need a subset of these
    */
   //private Set statements = new LinkedHashSet();
   
    /**
     * Set of type Packer
     */
    private Set packers = new HashSet();
   

   /**
    * The cert title selected by the user for this certificate
    */
   private CertTitle certTitle = null;
   
    private String approvalNo = null;
    private String approvalDate = null;
    private String applicationDateTime = null;
    private String applicantBusinessId = null;
    private String certExpiryDate = null;
    private String certificateNumber = null;
    private String consignor = null;
    private String consignee = null;
    private String countryOfOrigin = null;
    private String createdDate = null;
    private String createdBy = null;
    private String dateOfDispatch = null;
    private String destination = null;
    private String issueDate = null;
    private String issuedBy = null;
    private String meansOfTransport = null;
    private String other = null;
    private String plantSourceForSvs = null;
    private String placeOfDispatch = null;
    private String receiptDateTime = null;
    private String sourceCountryExRoi = null;
    private String supplementaryInfo = null;
    private String status = null;
    private String traderRef = null;
    private String typeOfPackaging = null;
    private String contactDetails = null;
   
    private UnitOfMeasure uom = null;
   
   
    public Set getPackers() {
      return packers;
   }


   public void setPackers(Set packers) {
      this.packers = packers;
   }

   public void addPacker(Packer packer) {
      
      this.packers.add(packer);
   }

   public String getApplicantBusinessId() {
      return applicantBusinessId;
   }


   public void setApplicantBusinessId(String applicantBusinessId) {
      this.applicantBusinessId = applicantBusinessId;
   }


   public String getApplicationDateTime() {
      return applicationDateTime;
   }


   public void setApplicationDateTime(String applicationDateTime) {
      this.applicationDateTime = applicationDateTime;
   }


   public String getApprovalDate() {
      return approvalDate;
   }


   public void setApprovalDate(String approvalDate) {
      this.approvalDate = approvalDate;
   }


   public String getApprovalNo() {
      return approvalNo;
   }


   public void setApprovalNo(String approvalNo) {
      this.approvalNo = approvalNo;
   }



   public String getCertExpiryDate() {
      return certExpiryDate;
   }


   public void setCertExpiryDate(String certExpiryDate) {
      this.certExpiryDate = certExpiryDate;
   }


   public CertType getCertType() {
      return certType;
   }


   public void setCertType(CertType certType) {
      this.certType = certType;
   }


   public String getConsignee() {
      return consignee;
   }


   public void setConsignee(String consignee) {
      this.consignee = consignee;
   }


   public String getConsignor() {
      return consignor;
   }


   public void setConsignor(String consignor) {
      this.consignor = consignor;
   }


   public String getCountryOfOrigin() {
      return countryOfOrigin;
   }


   public void setCountryOfOrigin(String countryOfOrigin) {
      this.countryOfOrigin = countryOfOrigin;
   }


   public String getDateOfDispatch() {
      return dateOfDispatch;
   }


   public void setDateOfDispatch(String dateOfDispatch) {
      this.dateOfDispatch = dateOfDispatch;
   }


   public String getDestination() {
      return destination;
   }


   public void setDestination(String destination) {
      this.destination = destination;
   }

   public String getIssueDate() {
      return issueDate;
   }


   public void setIssueDate(String issueDate) {
      this.issueDate = issueDate;
   }


   public String getIssuedBy() {
      return issuedBy;
   }


   public void setIssuedBy(String issuedBy) {
      this.issuedBy = issuedBy;
   }

   public String getMeansOfTransport() {
      return meansOfTransport;
   }


   public void setMeansOfTransport(String meansOfTransport) {
      this.meansOfTransport = meansOfTransport;
   }

   public String getOther() {
      return other;
   }


   public void setOther(String other) {
      this.other = other;
   }


   public String getPlaceOfDispatch() {
      return placeOfDispatch;
   }


   public void setPlaceOfDispatch(String placeOfDispatch) {
      this.placeOfDispatch = placeOfDispatch;
   }


   public String getPlantSourceForSvs() {
      return plantSourceForSvs;
   }


   public void setPlantSourceForSvs(String plantSourceForSvs) {
      this.plantSourceForSvs = plantSourceForSvs;
   }

   public String getReceiptDateTime() {
      return receiptDateTime;
   }


   public void setReceiptDateTime(String receiptDateTime) {
      this.receiptDateTime = receiptDateTime;
   }

   public String getSourceCountryExRoi() {
      return sourceCountryExRoi;
   }


   public void setSourceCountryExRoi(String sourceCountryExRoi) {
      this.sourceCountryExRoi = sourceCountryExRoi;
   }

   public String getSupplementaryInfo() {
      return supplementaryInfo;
   }


   public void setSupplementaryInfo(String supplementaryInfo) {
      this.supplementaryInfo = supplementaryInfo;
   }

   public String getTraderRef() {
      return traderRef;
   }


   public void setTraderRef(String traderRef) {
      this.traderRef = traderRef;
   }


   public String getTypeOfPackaging() {
      return typeOfPackaging;
   }


   public void setTypeOfPackaging(String typeOfPackaging) {
      this.typeOfPackaging = typeOfPackaging;
   }


   public String getCreatedBy() {
      return createdBy;
   }


   public void setCreatedBy(String createdBy) {
      this.createdBy = createdBy;
   }


   public String getCreatedDate() {
      return createdDate;
   }


   public void setCreatedDate(String createdDate) {
      this.createdDate = createdDate;
   }


   public long getCertificateId() {
      return certificateId;
   }


   public void setCertificateId(long id) {
      this.certificateId = id;
   }


   public String getStatus() {
      return status;
   }


   public void setStatus(String status) {
      this.status = status;
   }

   public Certificate() {
    }


//   public Set getStatements() {
//      return statements;
//   }
//
//
//   public void setStatements(Set statements) {
//      this.statements = statements;
//   }
//   
//   public void addStatement(Statement statement) {
//      
//      this.statements.add(statement);
//   }


   public CertTitle getCertTitle() {
      return certTitle;
   }


   public void setCertTitle(CertTitle certTitle) {
      this.certTitle = certTitle;
   }


   /**
    * @return the certificateNumber
    */
   public String getCertificateNumber() {
      return certificateNumber;
   }


   /**
    * @param certificateNumber the certificateNumber to set
    */
   public void setCertificateNumber(String certificateNumber) {
      this.certificateNumber = certificateNumber;
   }


   /**
    * @return the contactDetails
    */
   public String getContactDetails() {
      return contactDetails;
   }


   /**
    * @param contactDetails the contactDetails to set
    */
   public void setContactDetails(String contactDetails) {
      this.contactDetails = contactDetails;
   }


   /**
    * @return the uom
    */
   public UnitOfMeasure getUom() {
      return uom;
   }


   /**
    * @param uom the uom to set
    */
   public void setUom(UnitOfMeasure uom) {
      this.uom = uom;
   }
}



Packer
Code:
package ie.gov.agriculture.dpcs.cert;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

public class Packer implements Serializable{

   /**
    *
    */
   private static final long serialVersionUID = 1L;
   
   private Long packerId = Long.valueOf(0L);
   private String address = null;
    private String approvalNumber;
    private String batchSerialNumber = null;
    private String genericProductName = null;
    private String netWeight = null;
    private boolean milkRoi = false;
    private String plantSourceForSvs = null;
    private String placeOfDispatch = null;
    private String dateOfDispatch = null;
    private String destination = null;
    private String productDescription = null;
    private String productExpiryDate = null;
    private String productionCodes = null;
    private String quantity;
    private String sourceCountryExRoi;
    private String typeOfPackaging;
    private String name = null;
    private boolean manufacturerSameAsPacker = false;
    private UnitOfMeasure uom = null;
   
    private Set manufacturers = new HashSet();

   
    /**
     *
     * @param manuf add a Manufacturer to this packer
     */
    public void addManufacturer(Manufacturer manuf) {
       
       this.manufacturers.add(manuf);
    }

   /**
    * @return the manufacturers
    */
   public Set getManufacturers() {
      return manufacturers;
   }


   /**
    * @param manufacturers the manufacturers to set
    */
   public void setManufacturers(Set manufacturers) {
      this.manufacturers = manufacturers;
   }


   public String getAddress() {
      return address;
   }


   public void setAddress(String address) {
      this.address = address;
   }


   public String getApprovalNumber() {
      return approvalNumber;
   }


   public void setApprovalNumber(String approvalNo) {
      this.approvalNumber = approvalNo;
   }


   public String getBatchSerialNumber() {
      return batchSerialNumber;
   }


   public void setBatchSerialNumber(String batchSerialNo) {
      this.batchSerialNumber = batchSerialNo;
   }


   public String getGenericProductName() {
      return genericProductName;
   }


   public void setGenericProductName(String genericProductName) {
      this.genericProductName = genericProductName;
   }


   public boolean isMilkRoi() {
      return milkRoi;
   }


   public void setMilkRoi(boolean milkRoi) {
      this.milkRoi = milkRoi;
   }


   public String getName() {
      return name;
   }


   public void setName(String name) {
      this.name = name;
   }


   public String getNetWeight() {
      return netWeight;
   }


   public void setNetWeight(String netWeight) {
      this.netWeight = netWeight;
   }


   public String getPlantSourceForSvs() {
      return plantSourceForSvs;
   }


   public void setPlantSourceForSvs(String plantSourceForSvs) {
      this.plantSourceForSvs = plantSourceForSvs;
   }


   public String getProductDescription() {
      return productDescription;
   }


   public void setProductDescription(String prodDesc) {
      this.productDescription = prodDesc;
   }


   public String getProductionCodes() {
      return productionCodes;
   }


   public void setProductionCodes(String productionCodes) {
      this.productionCodes = productionCodes;
   }


   public String getQuantity() {
      return quantity;
   }


   public void setQuantity(String quantity) {
      this.quantity = quantity;
   }


   public String getSourceCountryExRoi() {
      return sourceCountryExRoi;
   }


   public void setSourceCountryExRoi(String sourceCountryExRoi) {
      this.sourceCountryExRoi = sourceCountryExRoi;
   }


   public String getTypeOfPackaging() {
      return typeOfPackaging;
   }


   public void setTypeOfPackaging(String typeOfPackaging) {
      this.typeOfPackaging = typeOfPackaging;
   }


//   public String getUomId() {
//      return uomId;
//   }
//
//
//   public void setUomId(String uomId) {
//      this.uomId = uomId;
//   }


   public Long getPackerId() {
      return packerId;
   }


   public void setPackerId(Long packerId) {
      this.packerId = packerId;
   }


   public String getProductExpiryDate() {
      return productExpiryDate;
   }


   public void setProductExpiryDate(String productExpiryDate) {
      this.productExpiryDate = productExpiryDate;
   }


   public boolean isManufacturerSameAsPacker() {
      return manufacturerSameAsPacker;
   }


   public void setManufacturerSameAsPacker(boolean manufacturerSameAsPacker) {
      this.manufacturerSameAsPacker = manufacturerSameAsPacker;
   }


   /**
    * @return the placeOfDispatch
    */
   public String getPlaceOfDispatch() {
      return placeOfDispatch;
   }


   /**
    * @param placeOfDispatch the placeOfDispatch to set
    */
   public void setPlaceOfDispatch(String placeOfDispatch) {
      this.placeOfDispatch = placeOfDispatch;
   }


   /**
    * @return the dateOfDispatch
    */
   public String getDateOfDispatch() {
      return dateOfDispatch;
   }


   /**
    * @param dateOfDispatch the dateOfDispatch to set
    */
   public void setDateOfDispatch(String dateOfDispatch) {
      this.dateOfDispatch = dateOfDispatch;
   }


   /**
    * @return the destination
    */
   public String getDestination() {
      return destination;
   }


   /**
    * @param destination the destination to set
    */
   public void setDestination(String destination) {
      this.destination = destination;
   }


   /**
    * @return the uom
    */
   public UnitOfMeasure getUom() {
      return uom;
   }


   /**
    * @param uom the uom to set
    */
   public void setUom(UnitOfMeasure uom) {
      this.uom = uom;
   }
}


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 12:34 pm 
Senior
Senior

Joined: Mon Oct 23, 2006 5:12 am
Posts: 141
Location: Galicia, Spain
Try doing, instead of your code this one:

Session session = HibernateUtil.getSession();
HibernateUtil.beginTransaction();
certificate.setApplicationDateTime("29/11/2006");
Packer packer = new Packer();
packer.setName("Kerry Gold");

Manufacturer manuf = new Manufacturer();
manuf.setName("Kerry Golden");
//packer.addManufacturer(manuf);
packer.getManufacturers().add(manuf);

//certificate.addPacker(packer);
certificate.getPackers().add(packer);

session.save(certificate);

_________________
andresgr (--don't forget to rate)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 30, 2006 6:00 am 
Beginner
Beginner

Joined: Fri Oct 06, 2006 7:11 am
Posts: 32
Hi,

I think that the certificate.getPackers().add(packer); is doing the same thing as my addPacker method.

But my problem seems to have gone. I re-created the whole database and it seems to have fixed the problem.

I was a bit suspicious because I had the same mapping in other parts of my code which worked fine. So I re-created the whole database and it's working now.

thanks for you help.
Paul


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.