db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert S. Sfeir" <rob...@codepuccino.com>
Subject Re: Bug when using extent classes?
Date Sun, 18 Jul 2004 17:45:14 GMT
Oh I should add one more thing to this.  the test first presists the  
object as a TicketBean, not a TicketDetail bean.  This might be a  
special case which makes thigns fail.

public Ticket getTicket() throws DataAccessException
     {
         Calendar cal = Calendar.getInstance();
         Long l = new Long(cal.getTimeInMillis());
         Ticket ticket =  
TrackerBeanFactory.getInstance("com.codepuccino.tracker.beans.ojb.Tracke 
rOJBBeanFactory").createTicket(new Integer(9999),
                                                                          
                                            new Integer(9999),
                                                                          
                                            new Integer(9999),
                                                                          
                                            new Integer(9999),
                                                                          
                                            new Integer(9999),
                                                                          
                                            new Integer(9999),
                                                                          
                                            new Integer(9999),
                                                                          
                                            new Integer(9999),
                                                                          
                                            new Integer(9999),
                                                                          
                                            new Integer(9999),
                                                                          
                                            new Integer(9999),
                                                                          
                                            "My unit test",
                                                                          
                                            "This is the description",
                                                                          
                                            "build 1234",
                                                                          
                                            new Integer(l.intValue()),
                                                                          
                                            new  
Timestamp(cal.getTimeInMillis()),
                                                                          
                                            new  
Timestamp(cal.getTimeInMillis()),
                                                                          
                                            new  
Timestamp(cal.getTimeInMillis()),
                                                                          
                                            "Robert S. Sfeir",
                                                                          
                                            "robert@codepuccno.com",
                                                                          
                                            new Integer(1),"new");
         return ticket;
     }

public void testPersistTicket() throws Exception
     {
         ObjectManagerDAO omd = new ObjectManagerDAOImpl();
         omd.persistObject(getTicket());
         Ticket t = (TicketDetailBean)  
omd.retrieveObjectDetail(TrackerBeanFactory.getInstance("com.codepuccino 
.tracker.beans.ojb.TrackerOJBBeanFactory").createTicketDetail(), new  
Integer(9999), "ID");
         assertEquals("Ticket ID should be 9999", t.getID().toString(),  
"9999");
         assertEquals("Ticket Subject should be My unit test",  
t.getSubject(), "My unit test");
     }




On Jul 18, 2004, at 1:42 PM, Robert S. Sfeir wrote:

> Did I just find a bug?
> The following line of code is from a test case:
>
>         Ticket t = (TicketDetailBean)  
> omd.retrieveObjectDetail(TrackerBeanFactory.getInstance("com.codepuccin 
> o.tracker.beans.ojb.TrackerOJBBeanFactory").createTicketDetail(), new  
> Integer(9999), "ID");
>
> createTicketDetail() returns a new TicketDetailBean()
>
> Ticket is an interface which is implemented by TicketBean and  
> TicketDetailBean.  Difference between the two is that one holds  
> reference objects to other tables the other one doesn't.
>
> My repository is setup as follows:
>
> <class-descriptor class="com.codepuccino.tracker.beans.Ticket">
>     <extent-class  
> class-ref="com.codepuccino.tracker.beans.ojb.TicketDetailBean"/>
>     <extent-class  
> class-ref="com.codepuccino.tracker.beans.ojb.TicketBean"/>
> </class-descriptor>
>
> with each appropriate class descriptor for each:
>
> <class-descriptor  
> class="com.codepuccino.tracker.beans.ojb.TicketDetailBean"  
> table="CDPCNO_TICKETS">
> ...
> </class-descriptor>
>
> <class-descriptor class="com.codepuccino.tracker.beans.ojb.TicketBean"  
> table="CDPCNO_TICKETS">
> ...
> </class-descriptor>
>
> I've setup a unit test to test persisting and retrieving the object.
>
> When I run the test the information is passed in correctly as evident  
> by my debugger's info:
>
> retriveObjectDetail(Object, Integer, String)
> Object is what I am looking for, in this case: TicketDetailBean
> Integer:  the ID of the Object
> String: The primary key col I am matching by: "ID" in this case.
>
> The debugger shows all 3 values as being correct including the Object  
> being TicketDetailBean with null values.
>
> When I call the method, the following info is processed:
>
> 	Criteria crit = new Criteria();
>             crit.addEqualTo(theColumn, theID);
>             Query query = QueryFactory.newQuery(bean.getClass(), crit);
>             object = broker.getObjectByQuery(query);
>
> bean.getClass() returns the proper object, TicketDeailBean
> when broker.getObjectByQuery(query) is executed it returns...   
> TicketBean... This of course causes a ClassCastException.
>
> HUH?
>
> Am I doing something unsupported here?
>
> R
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org


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


Mime
View raw message