Of course!

Its a FAQ item that assigned ids including composite ids can't distinguish
between a
saved or unsaved object (you have a choice between "always update" or
"always insert").

So if you want to add a new child (with unsaved-value="none"), simply save
() it
manually first:

child.setParent(parent);
parent.addChild(child);
session.save(child);
session.update(parent);

None of these things are issues if you use synthetic ids, as is best
practice for all
sorts of other reasons (see Scott Ambler's paper).





                                                                                       
                                               
                    "Raible, Matt"                                                     
                                               
                    <[EMAIL PROTECTED]>         To:     "'[EMAIL PROTECTED]'"          
               
                    Sent by:                                 <[EMAIL PROTECTED]>       
                           
                    [EMAIL PROTECTED]       cc:                                        
                               
                    eforge.net                              Subject:     [Hibernate] 
composite-id still doesn't work for me...        
                                                                                       
                                               
                                                                                       
                                               
                    23/01/03 05:10 AM                                                  
                                               
                                                                                       
                                               
                                                                                       
                                               




I just did a fresh checkout from CVS and updated my hibernate version.  I
can still retrieve data (and children) just fine, but not save it.

I noticed now that <composite-id>'s "unsaved-value" only allows "any" and
"none" - however, neither of these work for me:

        <composite-id name="id" unsaved-value="none"
            class="com.comcast.cable.dmc.itd.cct.persistence.CCRChildId">
            <key-property column="CCR_ID" name="ccrId" type="long"/>
            <key-property column="RECORD_NUM" name="recordNum" type
="long"/>
        </composite-id>

results in:

    [junit] WARN [main] JDBCExceptionReporter.logExceptions(35) | SQL
Error:
1407, SQLState: 72000
    [junit] ERROR [main] JDBCExceptionReporter.logExceptions(42) |
ORA-01407: cannot update ("CCTADM
IN"."CMCF_MPS"."CCR_ID") to NULL

If I set unsaved-value="any", then I get:

    [junit] WARN [main] JDBCExceptionReporter.logExceptions(35) | SQL
Error:
1, SQLState: 23000
    [junit] ERROR [main] JDBCExceptionReporter.logExceptions(42) |
ORA-00001: unique constraint (CCT
ADMIN.CMCF_MPS_PK) violated

My <bag> mapping to this class is:

        <bag role="mpsList" table="CMCF_MPS" cascade="all"
order-by="record_num">
            <key column="CCR_ID"/>
            <one-to-many
class="com.comcast.cable.dmc.itd.cct.persistence.CMCFMps"/>
        </bag>

I guess I'll remove my "bag" mappings and populate my child object manually
as this obviously isn't working for me ;-)

Thanks,

Matt




-------------------------------------------------------
This SF.net email is sponsored by: Scholarships for Techies!
Can't afford IT training? All 2003 ictp students receive scholarships.
Get hands-on training in Microsoft, Cisco, Sun, Linux/UNIX, and more.
www.ictp.com/training/sourceforge.asp
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel




**********************************************************************
Any personal or sensitive information contained in this email and
attachments must be handled in accordance with the Victorian Information
Privacy Act 2000, the Health Records Act 2001 or the Privacy Act 1988
(Commonwealth), as applicable.

This email, including all attachments, is confidential.  If you are not the
intended recipient, you must not disclose, distribute, copy or use the
information contained in this email or attachments.  Any confidentiality or
privilege is not waived or lost because this email has been sent to you in
error.  If you have received it in error, please let us know by reply
email, delete it from your system and destroy any copies.
**********************************************************************





-------------------------------------------------------
This SF.net email is sponsored by: Scholarships for Techies!
Can't afford IT training? All 2003 ictp students receive scholarships.
Get hands-on training in Microsoft, Cisco, Sun, Linux/UNIX, and more.
www.ictp.com/training/sourceforge.asp
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to