hi ,

have a look at the testcases using person and project.
these samples are part of ojb.

jakob

----- Original Message -----
From: "Qualita" <[EMAIL PROTECTED]>
To: "Lista OJB" <[EMAIL PROTECTED]>
Sent: Friday, September 06, 2002 8:44 PM
Subject: BUG mapping n:n OJB


> Hi,
>
> Somebody knows a simple example of OJB application
> that has supported mapping N:N? It would be possible
> to divulge for us?
>
> In attach it is our example based on tutorial 3 that
> have problems.
>
> In the class UCEnterNewRole, we use class/object
> intermediate (role) and only this object is store in
> the DB, but the others not.
>
> In the class UCEnterNewRole1, we don't use
> class/object intermediate and then only this is not
> store. Somebody can help us?
>
> Thanks,
>
> Alex / Tiago
>
> _______________________________________________________________________
> Yahoo! PageBuilder
> O super editor para cria��o de sites: � gr�tis, f�cil e r�pido.
> http://br.geocities.yahoo.com/v/pb.html


----------------------------------------------------------------------------
----


> //package test.ojb.tutorial1;
>
> import org.apache.ojb.broker.PersistenceBroker;
> import org.apache.ojb.broker.PersistenceBrokerException;
>
> /**
>  * Insert the type's description here.
>  * Creation date: (04.03.2001 10:34:15)
>  * @author: Administrator
>  */
> public class UCEnterNewRole extends AbstractUseCase
> {
>     /**
>      * UCEnterNewProduct constructor comment.
>      */
>     public UCEnterNewRole(PersistenceBroker broker)
>     {
>         super(broker);
>     }
>
>     /** perform this use case*/
>     public void apply()
>     {
>
>         //Insert the Person
>         Person newPerson = new Person();
>         // now read in all relevant information and fill the new object:
>         System.out.println("please enter a new person");
>
>         String in = readLineWithMessage("enter ID :");
>         newPerson.setId(Integer.parseInt(in));
>         in = readLineWithMessage("enter First name:");
>         newPerson.setFirstname(in);
>         in = readLineWithMessage("enter Last name:");
>         newPerson.setLastname(in);
>
>
>         //Insert the Project
>         Project newProject = new Project();
>         // now read in all relevant information and fill the new object:
>         System.out.println("please enter a new Project");
>         in = readLineWithMessage("enter ID :");
>         newProject.setId(Integer.parseInt(in));
>         in = readLineWithMessage("enter Title:");
>         newProject.setTitle(in);
>         in = readLineWithMessage("enter Description:");
>         newProject.setDescription(in);
>
>
>         // this will be our new object
>         Role newRole = new Role();
>         // now read in all relevant information and fill the new object:
>         System.out.println("please enter a new Role (n:m)");
>         in = readLineWithMessage("enter PERSON_ID :");
>         newRole.setPerson_id(Integer.parseInt(in));
>         in = readLineWithMessage("enter PROJECT_ID :");
>         newRole.setProject_id(Integer.parseInt(in));
>
>         in = readLineWithMessage("enter Role name:");
>         newRole.setRoleName(in);
>
>         newRole.setProject(newProject);
>         newRole.setPerson(newPerson);
>
>         // now perform persistence operations
>         try
>         {
>             System.out.println("Dentro do try");
>
>             System.out.println(newRole.getRoleName());
>
>             if (newRole == null) System.out.println("Eh null");
>
>             System.out.println(newRole);
>             // 1. open transaction
>             System.out.println("1");
>             broker.beginTransaction();
> System.out.println("2 , antes do store");
>             // 2. make the new object persistent
>
>             broker.store(newProject);
>
>             System.out.println("3");
>             broker.commitTransaction();
>         }
>         catch (Exception ex)
>         {
>             System.out.println("ERRO ->"+ex);
>
>             // if something went wrong: rollback
>             broker.abortTransaction();
>             System.out.println(ex.getMessage());
>             ex.printStackTrace();
>         }
>     }
>
>     /** get descriptive information on use case*/
>     public String getDescription()
>     {
>         return "Enter a new Role (n:m)";
>     }
> }
>


----------------------------------------------------------------------------
----


> //package test.ojb.tutorial1;
>
> import org.apache.ojb.broker.PersistenceBroker;
> import org.apache.ojb.broker.PersistenceBrokerException;
> import org.apache.ojb.broker.*;
> /**
>  * Insert the type's description here.
>  * Creation date: (04.03.2001 10:34:15)
>  * @author: Administrator
>  */
> public class UCEnterNewRole1 extends AbstractUseCase
> {
>     /**
>      * UCEnterNewProduct constructor comment.
>      */
>     public UCEnterNewRole1(PersistenceBroker broker)
>     {
>         super(broker);
>     }
>
>     /** perform this use case*/
>     public void apply()
>     {
>
>         //Insert the Person
>         Person newPerson = new Person();
>         // now read in all relevant information and fill the new object:
>         System.out.println("please enter a new person");
>
>         String in = readLineWithMessage("enter ID :");
>         newPerson.setId(Integer.parseInt(in));
>         in = readLineWithMessage("enter First name:");
>         newPerson.setFirstname(in);
>         in = readLineWithMessage("enter Last name:");
>         newPerson.setLastname(in);
>
>
>         //Insert the Project
>         Project newProject = new Project();
>         // now read in all relevant information and fill the new object:
>         System.out.println("please enter a new Project");
>         in = readLineWithMessage("enter ID :");
>         newProject.setId(Integer.parseInt(in));
>         in = readLineWithMessage("enter Title:");
>         newProject.setTitle(in);
>         in = readLineWithMessage("enter Description:");
>         newProject.setDescription(in);
>
>    /*
>         // this will be our new object
>         Role newRole = new Role();
>         // now read in all relevant information and fill the new object:
>         System.out.println("please enter a new Role (n:m)");
>         in = readLineWithMessage("enter PERSON_ID :");
>         newRole.setPerson_id(Integer.parseInt(in));
>         in = readLineWithMessage("enter PROJECT_ID :");
>         newRole.setProject_id(Integer.parseInt(in));
>
>         in = readLineWithMessage("enter Role name:");
>         newRole.setRoleName(in);
>
>         newRole.setProject(newProject);
>         newRole.setPerson(newPerson);
>    */
>         // now perform persistence operations
>         try
>         {
>             System.out.println("Dentro do try");
>
>             //System.out.println(.getRoleName());
>
>             //if (newRole == null) System.out.println("Eh null");
>
>             //System.out.println(newRole);
>             // 1. open transaction
>             System.out.println("1");
>             broker.beginTransaction();
> System.out.println("2 , antes do store");
>             // 2. make the new object persistent
>             broker.store(newProject);
>             broker.store(newPerson);
>             System.out.println("3");
>             broker.commitTransaction();
>         }
>         catch (Exception ex)
>         {
>             System.out.println("ERRO ->"+ex);
>
>             // if something went wrong: rollback
>             broker.abortTransaction();
>             System.out.println(ex.getMessage());
>             ex.printStackTrace();
>         }
>     }
>
>     /** get descriptive information on use case*/
>     public String getDescription()
>     {
>         return "Enter a new Role (n:m) sem classe intermediaria";
>     }
> }
>
>


----------------------------------------------------------------------------
----


> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to