You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Christoph Bohl <ch...@bohl.org> on 2004/02/02 19:51:44 UTC

Stored Procedure / returning primary key

Gurus, 
 
I try to use a stored procedure to insert a table. This works perfectly. The 
stored procedure does correctly return the values that get inserted into the 
database. 
 
Unfortunately, the object I am inserting does not change after the insert 
(toString() before and after). Can you please point out what I am doing wrong? 
Any help is greatly appreciated! 
 
The repository_user.xml: 
	<insert-procedure name="du$zollpartner_t_b.ins"> 
	    <runtime-argument field-ref="ztb_id" return="true"/> 
	    <runtime-argument field-ref="ztb_verband" return="true"/> 
	    <runtime-argument field-ref="ztb_rechtsform" return="true"/> 
	    <runtime-argument field-ref="ztb_anmeldedatum" return="true"/> 
	    <runtime-argument field-ref="ztb_unterlagenzustelldatum" 
return="true"/> 
	    <runtime-argument field-ref="ztb_gueltigv" return="true"/> 
	    <runtime-argument field-ref="ztb_gueltigb" return="true"/> 
	    <runtime-argument field-ref="ztb_erstuser" return="true"/> 
	    <runtime-argument field-ref="ztb_erstdat" return="true"/> 
	    <runtime-argument field-ref="ztb_mutuser" return="true"/> 
	    <runtime-argument field-ref="ztb_mutdat" return="true"/> 
	    <runtime-argument field-ref="ztb_zpa_id" return="true"/> 
  </insert-procedure> 
 
The Java code tested (Persistence Broker API): 
		PersistenceBroker broker = null; 
		 try 
		 { 
			 broker = 
PersistenceBrokerFactory.defaultPersistenceBroker(); 
			 broker.beginTransaction(); 
			 broker.store(ztb); 
			broker.commitTransaction(); 
		 } 
		 finally 
		 { 
			 if (broker != null) broker.close(); 
		 } 
 
ODMG API: 
//			Implementation odmg = OJB.getInstance(); 
//				   Database db = odmg.newDatabase(); 
//				   try { 
//			    
//					 db.open("TABI", 
Database.OPEN_READ_WRITE); 
//				   } catch (Exception e) { 
//					  System.out.println(e.toString()); 
//				   } 
//			    
//		TransactionExt tx = (TransactionExt) odmg.newTransaction(); 
//		System.out.println("vor insertf: " + ztb.toString()); 
// 
//		tx.begin(); 
//		tx.markDirty(ztb); 
//		tx.commit(); 
 
Thank you very much!! 
 
Cheers, 
Chris 
--  
"When you were born, you were crying and everyone around you was smiling. Live 
your life so that when you die, you’re the one who is smiling and everyone 
around you is crying." 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


RE: Stored Procedure / returning primary key

Posted by Christoph Bohl <ch...@bohl.org>.
This is the class-descriptor:

<class-descriptor
  class="ch.admin.bit.tabakbier.dto.Zollpartner_t_b"
  table="ZOLLPARTNER_T_B"
>
  <field-descriptor id="0"
    name="ztb_id"
    column="ZTB_ID"
    jdbc-type="DECIMAL"
    primarykey="true"
  />
  <field-descriptor id="1"
    name="ztb_verband"
    column="ZTB_VERBAND"
    jdbc-type="VARCHAR"
  />
  <field-descriptor id="2"
    name="ztb_rechtsform"
    column="ZTB_RECHTSFORM"
    jdbc-type="VARCHAR"
  />
  <field-descriptor id="3"
    name="ztb_anmeldedatum"
    column="ZTB_ANMELDEDATUM"
    jdbc-type="DATE"
  />
  <field-descriptor id="4"
    name="ztb_unterlagenzustelldatum"
    column="ZTB_UNTERLAGENZUSTELLDATUM"
    jdbc-type="DATE"
  />
  <field-descriptor id="5"
    name="ztb_gueltigv"
    column="ZTB_GUELTIGV"
    jdbc-type="DATE"
  />
  <field-descriptor id="6"
    name="ztb_gueltigb"
    column="ZTB_GUELTIGB"
    jdbc-type="DATE"
  />
  <field-descriptor id="7"
    name="ztb_erstuser"
    column="ZTB_ERSTUSER"
    jdbc-type="VARCHAR"
  />
  <field-descriptor id="8"
    name="ztb_erstdat"
    column="ZTB_ERSTDAT"
    jdbc-type="TIMESTAMP"
  />
  <field-descriptor id="9"
    name="ztb_mutuser"
    column="ZTB_MUTUSER"
    jdbc-type="VARCHAR"
  />
  <field-descriptor id="10"
    name="ztb_mutdat"
    column="ZTB_MUTDAT"
    jdbc-type="TIMESTAMP"
  />
  <field-descriptor id="11"
    name="ztb_zpa_id"
    column="ZTB_ZPA_ID"
    jdbc-type="DECIMAL"
  />
	<insert-procedure name="du$zollpartner_t_b.ins">
	    <runtime-argument field-ref="ztb_id" return="true"/>
	    <runtime-argument field-ref="ztb_verband" return="true"/>
	    <runtime-argument field-ref="ztb_rechtsform" return="true"/>
	    <runtime-argument field-ref="ztb_anmeldedatum" return="true"/>
	    <runtime-argument field-ref="ztb_unterlagenzustelldatum"
return="true"/>
	    <runtime-argument field-ref="ztb_gueltigv" return="true"/>
	    <runtime-argument field-ref="ztb_gueltigb" return="true"/>
	    <runtime-argument field-ref="ztb_erstuser" return="true"/>
	    <runtime-argument field-ref="ztb_erstdat" return="true"/>
	    <runtime-argument field-ref="ztb_mutuser" return="true"/>
	    <runtime-argument field-ref="ztb_mutdat" return="true"/>
	    <runtime-argument field-ref="ztb_zpa_id" return="true"/>
  </insert-procedure>
</class-descriptor>

Thank you very much for your help!

Regards,
Chris

On Tue, 2004-02-03 at 13:16, Ron Gallagher wrote:
> Chris --
> 
> Please provide the class descriptor that contains this insert-procedure
> element.
> 
> Ron.
> 
> -----Original Message-----
> From: Christoph Bohl [mailto:christoph@bohl.org]
> Sent: Monday, February 02, 2004 1:52 PM
> To: ojb-user@db.apache.org
> Subject: Stored Procedure / returning primary key
> 
> 
> Gurus,
> 
> I try to use a stored procedure to insert a table. This works perfectly. The
> stored procedure does correctly return the values that get inserted into the
> database.
> 
> Unfortunately, the object I am inserting does not change after the insert
> (toString() before and after). Can you please point out what I am doing
> wrong?
> Any help is greatly appreciated!
> 
> The repository_user.xml:
> 	<insert-procedure name="du$zollpartner_t_b.ins">
> 	    <runtime-argument field-ref="ztb_id" return="true"/>
> 	    <runtime-argument field-ref="ztb_verband" return="true"/>
> 	    <runtime-argument field-ref="ztb_rechtsform" return="true"/>
> 	    <runtime-argument field-ref="ztb_anmeldedatum" return="true"/>
> 	    <runtime-argument field-ref="ztb_unterlagenzustelldatum"
> return="true"/>
> 	    <runtime-argument field-ref="ztb_gueltigv" return="true"/>
> 	    <runtime-argument field-ref="ztb_gueltigb" return="true"/>
> 	    <runtime-argument field-ref="ztb_erstuser" return="true"/>
> 	    <runtime-argument field-ref="ztb_erstdat" return="true"/>
> 	    <runtime-argument field-ref="ztb_mutuser" return="true"/>
> 	    <runtime-argument field-ref="ztb_mutdat" return="true"/>
> 	    <runtime-argument field-ref="ztb_zpa_id" return="true"/>
>   </insert-procedure>
> 
> The Java code tested (Persistence Broker API):
> 		PersistenceBroker broker = null;
> 		 try
> 		 {
> 			 broker =
> PersistenceBrokerFactory.defaultPersistenceBroker();
> 			 broker.beginTransaction();
> 			 broker.store(ztb);
> 			broker.commitTransaction();
> 		 }
> 		 finally
> 		 {
> 			 if (broker != null) broker.close();
> 		 }
> 
> ODMG API:
> //			Implementation odmg = OJB.getInstance();
> //				   Database db = odmg.newDatabase();
> //				   try {
> //
> //					 db.open("TABI",
> Database.OPEN_READ_WRITE);
> //				   } catch (Exception e) {
> //					  System.out.println(e.toString());
> //				   }
> //
> //		TransactionExt tx = (TransactionExt) odmg.newTransaction();
> //		System.out.println("vor insertf: " + ztb.toString());
> //
> //		tx.begin();
> //		tx.markDirty(ztb);
> //		tx.commit();
> 
> Thank you very much!!
> 
> Cheers,
> Chris
> --
> "When you were born, you were crying and everyone around you was smiling.
> Live
> your life so that when you die, youre the one who is smiling and everyone
> around you is crying."
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


RE: Stored Procedure / returning primary key

Posted by Ron Gallagher <ro...@bellsouth.net>.
Chris --

Please provide the class descriptor that contains this insert-procedure
element.

Ron.

-----Original Message-----
From: Christoph Bohl [mailto:christoph@bohl.org]
Sent: Monday, February 02, 2004 1:52 PM
To: ojb-user@db.apache.org
Subject: Stored Procedure / returning primary key


Gurus,

I try to use a stored procedure to insert a table. This works perfectly. The
stored procedure does correctly return the values that get inserted into the
database.

Unfortunately, the object I am inserting does not change after the insert
(toString() before and after). Can you please point out what I am doing
wrong?
Any help is greatly appreciated!

The repository_user.xml:
	<insert-procedure name="du$zollpartner_t_b.ins">
	    <runtime-argument field-ref="ztb_id" return="true"/>
	    <runtime-argument field-ref="ztb_verband" return="true"/>
	    <runtime-argument field-ref="ztb_rechtsform" return="true"/>
	    <runtime-argument field-ref="ztb_anmeldedatum" return="true"/>
	    <runtime-argument field-ref="ztb_unterlagenzustelldatum"
return="true"/>
	    <runtime-argument field-ref="ztb_gueltigv" return="true"/>
	    <runtime-argument field-ref="ztb_gueltigb" return="true"/>
	    <runtime-argument field-ref="ztb_erstuser" return="true"/>
	    <runtime-argument field-ref="ztb_erstdat" return="true"/>
	    <runtime-argument field-ref="ztb_mutuser" return="true"/>
	    <runtime-argument field-ref="ztb_mutdat" return="true"/>
	    <runtime-argument field-ref="ztb_zpa_id" return="true"/>
  </insert-procedure>

The Java code tested (Persistence Broker API):
		PersistenceBroker broker = null;
		 try
		 {
			 broker =
PersistenceBrokerFactory.defaultPersistenceBroker();
			 broker.beginTransaction();
			 broker.store(ztb);
			broker.commitTransaction();
		 }
		 finally
		 {
			 if (broker != null) broker.close();
		 }

ODMG API:
//			Implementation odmg = OJB.getInstance();
//				   Database db = odmg.newDatabase();
//				   try {
//
//					 db.open("TABI",
Database.OPEN_READ_WRITE);
//				   } catch (Exception e) {
//					  System.out.println(e.toString());
//				   }
//
//		TransactionExt tx = (TransactionExt) odmg.newTransaction();
//		System.out.println("vor insertf: " + ztb.toString());
//
//		tx.begin();
//		tx.markDirty(ztb);
//		tx.commit();

Thank you very much!!

Cheers,
Chris
--
"When you were born, you were crying and everyone around you was smiling.
Live
your life so that when you die, you’re the one who is smiling and everyone
around you is crying."

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org