You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Jamie <ja...@stimulussoft.com> on 2009/09/17 09:46:44 UTC

Relationships Not Propagated

Hi Everyone

I am really struggling to use the Cayenne Modelling tool. It seems 
whenever I create an ObjectEntity from the DBEntity the relationships 
are not always propagated. This happens even when I follow the ARTIST 
tutorial. I tried both Cayenne 3.0M6 and Cayenne 2.0.4 and the same 
behaviour is observed. Is this a known bug or am I likely doing 
something horribly wrong?

Thank in advance


Jamie



Re: Relationships Not Propagated

Posted by Joe Baldwin <jf...@earthlink.net>.
Jamie,

I have found that the behavior of the Modeler is sometimes linked to  
the order in which you create ObjEntities and DbEntities.

I usually create the DbEntities first, then create the ObjEntities,  
then create the relationships. Once I do this then I select the "sync"  
button (Hover = "Sync Dependent ObjEntities with DbEntities")  in the  
DbEntity's dialog window (I do this for each DbEntity that I have  
created).

This usually synchronizes the ObjEntities relationships with the  
DbEntities relationships.

If I make significant changes to the DbEntities, then I always follow  
up with using the sync button for *each* DbEntity.

The only time this has not worked for me is when I have made some sort  
of mistake with defining the DbEntities.

There may be an easier way to do all this, but this has worked for me  
so far.

Joe


On Sep 17, 2009, at 3:46 AM, Jamie wrote:

> Hi Everyone
>
> I am really struggling to use the Cayenne Modelling tool. It seems  
> whenever I create an ObjectEntity from the DBEntity the  
> relationships are not always propagated. This happens even when I  
> follow the ARTIST tutorial. I tried both Cayenne 3.0M6 and Cayenne  
> 2.0.4 and the same behaviour is observed. Is this a known bug or am  
> I likely doing something horribly wrong?
>
> Thank in advance
>
>
> Jamie
>
>


Re: Relationships Not Propagated

Posted by Jamie <ja...@stimulussoft.com>.
Never mind. I figured it out. SQLResultSetMapping is now SQLResult.

Jamie wrote:
> Hi Michael
>
> Next question. I am trying to execute a query like:
>
> select distinct customer.companyName c, max(date) d from purchase 
> inner join customer on purchase.customerid = customer.id group by 
> customer.companyName"
>
> In doing so, I figured out I might need to use the SQLResultSetMapping 
> class to get at c and d, but this class does exist in the latest 
> cayenne-server-3.0M6.jar. What is the recommended approach?
>
> Thanks
>
> Jamie
>


Re: Relationships Not Propagated

Posted by Jamie <ja...@stimulussoft.com>.
Nevermind... I figured it out. SQLResultSetMapping is now SQLResult.

Jamie wrote:
> Hi Michael
>
> Next question. I am trying to execute a query like:
>
> select distinct customer.companyName c, max(date) d from purchase 
> inner join customer on purchase.customerid = customer.id group by 
> customer.companyName"
>
> In doing so, I figured out I might need to use the SQLResultSetMapping 
> class to get at c and d, but this class does exist in the latest 
> cayenne-server-3.0M6.jar. What is the recommended approach?
>
> Thanks
>
> Jamie
>
>
> Michael Gentry wrote:
>> I took a quick look at your model and it looks OK (given what I know
>> about what you are doing).
>>
>> One thing that may be worth trying is to change:
>>
>> Partner partner =
>> ((BusinessServicesPrincipal)request.getUserPrincipal()).getPartner();
>> DataContext context =
>> ((BusinessServicesPrincipal)request.getUserPrincipal()).getDataContext(); 
>>
>> Customer customer = (Customer) context.newObject(Customer.class);
>>
>> to:
>>
>> Partner partner =
>> ((BusinessServicesPrincipal)request.getUserPrincipal()).getPartner();
>> Customer customer = partner.getDataContext().newObject(Customer.class);
>>
>> It may not solve anything, but worth a shot.  I'm assuming you are
>> using Cayenne 3.x?
>>   
>


-- 
Stimulus Software - MailArchiva
Email Archiving And Compliance
USA Tel: +1-713-343-8824 ext 100
UK Tel: +44-20-80991035 ext 100
Email:  jamie@stimulussoft.com
Web: http://www.mailarchiva.com
To receive MailArchiva Enterprise Edition product announcements, send a message to: <ma...@stimulussoft.com>


Re: Relationships Not Propagated

Posted by Jamie <ja...@stimulussoft.com>.
Hi Michael

Next question. I am trying to execute a query like:

select distinct customer.companyName c, max(date) d from purchase inner 
join customer on purchase.customerid = customer.id group by 
customer.companyName"

In doing so, I figured out I might need to use the SQLResultSetMapping 
class to get at c and d, but this class does exist in the latest 
cayenne-server-3.0M6.jar. What is the recommended approach?

Thanks

Jamie


Michael Gentry wrote:
> I took a quick look at your model and it looks OK (given what I know
> about what you are doing).
>
> One thing that may be worth trying is to change:
>
> Partner partner =
> ((BusinessServicesPrincipal)request.getUserPrincipal()).getPartner();
> DataContext context =
> ((BusinessServicesPrincipal)request.getUserPrincipal()).getDataContext();
> Customer customer = (Customer) context.newObject(Customer.class);
>
> to:
>
> Partner partner =
> ((BusinessServicesPrincipal)request.getUserPrincipal()).getPartner();
> Customer customer = partner.getDataContext().newObject(Customer.class);
>
> It may not solve anything, but worth a shot.  I'm assuming you are
> using Cayenne 3.x?
>   


Re: Relationships Not Propagated

Posted by Michael Gentry <mg...@masslight.net>.
Oh, you may have had the client jar there ... that is used for the
Cayenne ROP stuff.


On Fri, Sep 18, 2009 at 3:28 PM, Jamie <ja...@stimulussoft.com> wrote:
> Michael
>
> Ok. I found the source of the error. Without knowing the specific jar files
> that I needed, I incorporated all of them. Obviously, there was an
> overlapping  CayenneDataObject in one of the jar files that was causing a
> Null Pointer. To resolve I delete all jars but the cayenne server jar.
>
> Thanks in advance for your help!
>
> Jamie
>
>
>
> Jamie wrote:
>>
>> No such luck. What is on line 385 that would generate a Null Pointer
>> Exception? Null pointer is a pretty serious error.
>>
>> java.lang.NullPointerException
>>
>>
>>  org.apache.cayenne.CayenneDataObject.setReverseRelationship(CayenneDataObject.java:385)
>>
>>
>> Michael Gentry wrote:
>
>
> --
> Stimulus Software - MailArchiva
> Email Archiving And Compliance
> USA Tel: +1-713-343-8824 ext 100
> UK Tel: +44-20-80991035 ext 100
> Email:  jamie@stimulussoft.com
> Web: http://www.mailarchiva.com
> To receive MailArchiva Enterprise Edition product announcements, send a
> message to: <ma...@stimulussoft.com>
>
>

Re: Relationships Not Propagated

Posted by Jamie <ja...@stimulussoft.com>.
Michael

Ok. I found the source of the error. Without knowing the specific jar 
files that I needed, I incorporated all of them. Obviously, there was an 
overlapping  CayenneDataObject in one of the jar files that was causing 
a Null Pointer. To resolve I delete all jars but the cayenne server jar.

Thanks in advance for your help!

Jamie



Jamie wrote:
> No such luck. What is on line 385 that would generate a Null Pointer 
> Exception? Null pointer is a pretty serious error.
>
> java.lang.NullPointerException
>
>     org.apache.cayenne.CayenneDataObject.setReverseRelationship(CayenneDataObject.java:385) 
>
>
>
> Michael Gentry wrote:


-- 
Stimulus Software - MailArchiva
Email Archiving And Compliance
USA Tel: +1-713-343-8824 ext 100
UK Tel: +44-20-80991035 ext 100
Email:  jamie@stimulussoft.com
Web: http://www.mailarchiva.com
To receive MailArchiva Enterprise Edition product announcements, send a message to: <ma...@stimulussoft.com>


Re: Relationships Not Propagated

Posted by Jamie <ja...@stimulussoft.com>.
No such luck. What is on line 385 that would generate a Null Pointer 
Exception? Null pointer is a pretty serious error.

java.lang.NullPointerException

	org.apache.cayenne.CayenneDataObject.setReverseRelationship(CayenneDataObject.java:385)


Michael Gentry wrote:

Re: Relationships Not Propagated

Posted by Michael Gentry <mg...@masslight.net>.
I took a quick look at your model and it looks OK (given what I know
about what you are doing).

One thing that may be worth trying is to change:

Partner partner =
((BusinessServicesPrincipal)request.getUserPrincipal()).getPartner();
DataContext context =
((BusinessServicesPrincipal)request.getUserPrincipal()).getDataContext();
Customer customer = (Customer) context.newObject(Customer.class);

to:

Partner partner =
((BusinessServicesPrincipal)request.getUserPrincipal()).getPartner();
Customer customer = partner.getDataContext().newObject(Customer.class);

It may not solve anything, but worth a shot.  I'm assuming you are
using Cayenne 3.x?


On Fri, Sep 18, 2009 at 10:07 AM, Jamie <ja...@stimulussoft.com> wrote:
> Hi Michael
>
> See below:
>
> Michael Gentry wrote:
>>
>> Just do:
>>
>> partner.addToCustomers(customer);
>>
>> You don't need to do both lines.  How did you create partner and
>> customer?
>
> Partner partner =
> ((BusinessServicesPrincipal)request.getUserPrincipal()).getPartner();
> DataContext context =
> ((BusinessServicesPrincipal)request.getUserPrincipal()).getDataContext();
> Customer customer = (Customer) context.newObject(Customer.class);
>
> Actually, I have a Principal object that stores the DataContext and i use
> that through out. The context is only created once:
>
> DataContext context = DataContext.createDataContext();
>
>> Did you create partner in a DataContext or fetch it from
>> the DB?
>
> The Partner is obtained from the DB at the point where the partner logs in:
>
> List<Partner> partners = context.performQuery(select);
>          if (partners.size()>0) {
>              for (Partner partner : partners) {
>                  String pass = partner.getPassword();
>                  if (partner.getContactEmail()==username &&
> (partner.getPassword()==null || partner.getPassword().equals(password))) {
>                      return new
> BusinessServicesPrincipal("partner",partner,context);
>                  }
>              }
>          }
>          return null;
>
>>  Is customer created in the same DataContext as partner?
>>
>
> Yes. I ran into this error before. Now I DataContext everything in the
> Principal and access the Principal from the JSP.
>
> See attached for source and config files.
>>
>> mrg
>>
>>
>> On Fri, Sep 18, 2009 at 3:59 AM, Jamie <ja...@stimulussoft.com> wrote:
>>
>>>
>>> Hi Michael
>>>
>>> Thanks for the help. Next question. I have a one to many Partner ->
>>> Customer
>>> relationship defined.
>>> When creating a new customer, I try to setup the relationship as follows:
>>>
>>>        partner.addToCustomers(customer);
>>>        customer.setPartner(partner);
>>>
>>> I get a NullPointer, even though customer and partner are not null.
>>>
>>> SEVERE: Servlet.service() for servlet jsp threw exception
>>> java.lang.NullPointerException
>>>  at
>>>
>>> org.apache.cayenne.CayenneDataObject.setReverseRelationship(CayenneDataObject.java:385)
>>>  at
>>>
>>> org.apache.cayenne.CayenneDataObject.setToOneTarget(CayenneDataObject.java:339)
>>>  at com.stimulus.support.auto._Customer.setPartner(_Customer.java:97)
>>>  at
>>> org.apache.jsp.customerdetail_jsp._jspService(customerdetail_jsp.java:94)
>>>  at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
>>>  at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>>>  at
>>>
>>> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
>>>  at
>>> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
>>>  at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
>>>  at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>>>  at
>>>
>>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>>>  at
>>>
>>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>>>  at
>>>
>>> org.apache.cayenne.conf.WebApplicationContextFilter.doFilter(WebApplicationContextFilter.java:91)
>>>  at
>>>
>>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
>>>  at
>>>
>>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>>>  at
>>>
>>> org.securityfilter.filter.SecurityFilter.doFilter(SecurityFilter.java:188)
>>>  at
>>>
>>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
>>>  at
>>>
>>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>>>  at
>>>
>>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
>>>  at
>>>
>>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
>>>  at
>>>
>>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
>>>  at
>>>
>>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>>>  at
>>>
>>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>>>  at
>>>
>>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
>>>  at
>>>
>>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
>>>  at
>>>
>>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
>>>  at
>>> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
>>>  at java.lang.Thread.run(Thread.java:619)
>>>
>>> Any ideas?
>>>
>>> Jamie
>>>
>>> Michael Gentry wrote:
>>>
>>>>
>>>> When you create a brand new ObjEntity from a DBEntity, it propagates
>>>> all attributes and relationships defined in the DBEntity except for
>>>> the primary key (Cayenne Modeler assumes you don't need that exposed).
>>>>  Once you've created the ObjEntity, though, adding a new relationship
>>>> to the DBEntity will not be automatically synced to the ObjEntity.
>>>> You have to sync it manually (click the double-arrow icon in either
>>>> the DBEntity or ObjEntity toolbar or use the Project menu or keyboard
>>>> shortcut).  I'm talking mainly about 3.0M6 since I no longer use the
>>>> 2.x modeler and don't remember the exact specifics of how it behaves.
>>>>
>>>> mrg
>>>>
>>>>
>>>> On Thu, Sep 17, 2009 at 3:46 AM, Jamie <ja...@stimulussoft.com> wrote:
>>>>
>>>>
>>>>>
>>>>> Hi Everyone
>>>>>
>>>>> I am really struggling to use the Cayenne Modelling tool. It seems
>>>>> whenever
>>>>> I create an ObjectEntity from the DBEntity the relationships are not
>>>>> always
>>>>> propagated. This happens even when I follow the ARTIST tutorial. I
>>>>> tried
>>>>> both Cayenne 3.0M6 and Cayenne 2.0.4 and the same behaviour is
>>>>> observed.
>>>>> Is
>>>>> this a known bug or am I likely doing something horribly wrong?
>>>>>
>>>>> Thank in advance
>>>>>
>>>>>
>>>>> Jamie
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
> --
> Stimulus Software - MailArchiva
> Email Archiving And Compliance
> USA Tel: +1-713-343-8824 ext 100
> UK Tel: +44-20-80991035 ext 100
> Email:  jamie@stimulussoft.com
> Web: http://www.mailarchiva.com
> To receive MailArchiva Enterprise Edition product announcements, send a
> message to: <ma...@stimulussoft.com>
>
>
> <%@ page language="java" contentType="text/html" %>
> <%@ page import="org.apache.cayenne.*" %>
> <%@ page import="org.apache.cayenne.access.*" %>
> <%@ page import="java.util.*" %>
> <%@ page import="java.text.*" %>
> <%@ page import="com.stimulus.support.*" %>
> <%@ page import="com.stimulus.support.realm.*"%>
> <%
>        Partner partner =
> ((BusinessServicesPrincipal)request.getUserPrincipal()).getPartner();
> out.println(partner.getCompanyName());
>    DataContext context =
> ((BusinessServicesPrincipal)request.getUserPrincipal()).getDataContext();
>    String id = request.getParameter("id");
>    Customer customer = null;
>    if(id != null && id.trim().length() > 0) {
>        customer = (Customer) DataObjectUtils.objectForPK(context,
> Customer.class, Integer.parseInt(id));
>    }
>
>    if("POST".equals(request.getMethod())) {
>        if (request.getParameter("delete")!=null) {
>                out.println(request.getParameter("delete"));
>                customer = (Customer) DataObjectUtils.objectForPK(context,
> Customer.class, Integer.parseInt(id));
>                partner.removeFromCustomers(customer);
>                context.deleteObject(customer);
>        } else {
>                if(customer == null) {
>                        customer = (Customer)
> context.newObject(Customer.class);
>                }
>                customer.setCompanyName(request.getParameter("companyName"));
>
>  customer.setTechnicalContactEmail(request.getParameter("technicalContactEmail"));
>
>  customer.setTechnicalContactName(request.getParameter("technicalContactName"));
>
>  customer.setTechnicalContactTel(request.getParameter("technicalContactTel"));
>
>  customer.setFinanceContactEmail(request.getParameter("financeContactEmail"));
>
>  customer.setFinanceContactName(request.getParameter("financeContactName"));
>
>  customer.setFinanceContactTel(request.getParameter("financeContactTel"));
>                partner.addToCustomers(customer);
>
>        }
>        context.commitChanges();
>        response.sendRedirect("managecustomers.jsp");
>    }
>
>    if(customer == null) {
>        customer = new Customer();
>    }
>
>    String companyName =
> customer.getCompanyName()==null?"":customer.getCompanyName();
>    String technicalContactEmail  = customer.getTechnicalContactEmail()
> ==null? "":customer.getTechnicalContactEmail();
>    String technicalContactName = customer.getTechnicalContactName()==null ?
> "":customer.getTechnicalContactName();
>    String technicalContactTel = customer.getTechnicalContactTel()==null ?
> "":customer.getTechnicalContactTel();
>
>    String financeContactEmail  = customer.getFinanceContactEmail() ==null?
> "":customer.getFinanceContactEmail();
>    String financeContactName = customer.getFinanceContactName()==null ?
> "":customer.getFinanceContactName();
>    String financeContactTel = customer.getFinanceContactTel()==null ?
> "":customer.getFinanceContactTel();
> %>
> <html>
>    <head>
>        <title>Customer Details</title>
>    </head>
>    <body>
>        <img src="images/mailarchiva_logo.jpg" alt="MailArchiva" />
>        <h2>Customer Details</h2>
>        <form name="EditCustomer" action="customerdetail.jsp" method="POST">
>            <input type="hidden" name="id" value="<%= id != null ? id : ""
> %>" />
>            <table border="0">
>                <tr>
>                    <td>Company Name:</td>
>                    <td><input type="text" name="companyName" value="<%=
> companyName %>"/></td>
>                </tr>
>                <tr>
>                    <td>Technical Contact Name:</td>
>                    <td><input type="text" name="technicalContactName"
> value="<%= technicalContactName %>"/></td>
>                </tr>
>                <tr>
>                    <td>Technical Contact Email:</td>
>                    <td><input type="text" name="technicalContactEmail"
> value="<%= technicalContactEmail %>"/></td>
>                </tr>
>                <tr>
>                    <td>Technical Contact Tel.:</td>
>                    <td><input type="text" name="technicalContactTel"
> value="<%= technicalContactTel %>"/></td>
>                </tr>
>                <tr>
>                    <td>Finance Contact Name:</td>
>                    <td><input type="text" name="financeContactName"
> value="<%= financeContactName %>"/></td>
>                </tr>
>                <tr>
>                    <td>Finance Contact Email:</td>
>                    <td><input type="text" name="financeContactEmail"
> value="<%= financeContactEmail %>"/></td>
>                </tr>
>                <tr>
>                    <td>Finance Contact Tel.:</td>
>                    <td><input type="text" name="financeContactTel"
> value="<%= financeContactTel %>"/></td>
>                </tr>
>
>                <tr>
>                    <td></td>
>                    <td align="right"><input type="submit" name="save"
> value="Save" /></td>
>                    <td align="right"><input type="submit" name="delete"
> value="Delete" /></td>
>                </tr>
>            </table>
>        </form>
>        <p><a href="managecustomers.jsp">Back...</a></p>
>    </body>
> </html>
>

Re: Relationships Not Propagated

Posted by Jamie <ja...@stimulussoft.com>.
Hi Michael

See below:

Michael Gentry wrote:
> Just do:
>
> partner.addToCustomers(customer);
>
> You don't need to do both lines.  How did you create partner and
> customer?  
Partner partner = 
((BusinessServicesPrincipal)request.getUserPrincipal()).getPartner();
DataContext context = 
((BusinessServicesPrincipal)request.getUserPrincipal()).getDataContext();
Customer customer = (Customer) context.newObject(Customer.class);

Actually, I have a Principal object that stores the DataContext and i 
use that through out. The context is only created once:

DataContext context = DataContext.createDataContext();

> Did you create partner in a DataContext or fetch it from
> the DB? 

The Partner is obtained from the DB at the point where the partner logs in:

List<Partner> partners = context.performQuery(select);
           if (partners.size()>0) {
               for (Partner partner : partners) {
                   String pass = partner.getPassword();
                   if (partner.getContactEmail()==username && 
(partner.getPassword()==null || partner.getPassword().equals(password))) {
                       return new 
BusinessServicesPrincipal("partner",partner,context);
                   }
               }
           }
           return null;

>  Is customer created in the same DataContext as partner?
>   
Yes. I ran into this error before. Now I DataContext everything in the 
Principal and access the Principal from the JSP.

See attached for source and config files.
> mrg
>
>
> On Fri, Sep 18, 2009 at 3:59 AM, Jamie <ja...@stimulussoft.com> wrote:
>   
>> Hi Michael
>>
>> Thanks for the help. Next question. I have a one to many Partner -> Customer
>> relationship defined.
>> When creating a new customer, I try to setup the relationship as follows:
>>
>>         partner.addToCustomers(customer);
>>         customer.setPartner(partner);
>>
>> I get a NullPointer, even though customer and partner are not null.
>>
>> SEVERE: Servlet.service() for servlet jsp threw exception
>> java.lang.NullPointerException
>>   at
>> org.apache.cayenne.CayenneDataObject.setReverseRelationship(CayenneDataObject.java:385)
>>   at
>> org.apache.cayenne.CayenneDataObject.setToOneTarget(CayenneDataObject.java:339)
>>   at com.stimulus.support.auto._Customer.setPartner(_Customer.java:97)
>>   at
>> org.apache.jsp.customerdetail_jsp._jspService(customerdetail_jsp.java:94)
>>   at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
>>   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>>   at
>> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
>>   at
>> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
>>   at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
>>   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>>   at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>>   at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>>   at
>> org.apache.cayenne.conf.WebApplicationContextFilter.doFilter(WebApplicationContextFilter.java:91)
>>   at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
>>   at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>>   at
>> org.securityfilter.filter.SecurityFilter.doFilter(SecurityFilter.java:188)
>>   at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
>>   at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>>   at
>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
>>   at
>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
>>   at
>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
>>   at
>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>>   at
>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>>   at
>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
>>   at
>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
>>   at
>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
>>   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
>>   at java.lang.Thread.run(Thread.java:619)
>>
>> Any ideas?
>>
>> Jamie
>>
>> Michael Gentry wrote:
>>     
>>> When you create a brand new ObjEntity from a DBEntity, it propagates
>>> all attributes and relationships defined in the DBEntity except for
>>> the primary key (Cayenne Modeler assumes you don't need that exposed).
>>>  Once you've created the ObjEntity, though, adding a new relationship
>>> to the DBEntity will not be automatically synced to the ObjEntity.
>>> You have to sync it manually (click the double-arrow icon in either
>>> the DBEntity or ObjEntity toolbar or use the Project menu or keyboard
>>> shortcut).  I'm talking mainly about 3.0M6 since I no longer use the
>>> 2.x modeler and don't remember the exact specifics of how it behaves.
>>>
>>> mrg
>>>
>>>
>>> On Thu, Sep 17, 2009 at 3:46 AM, Jamie <ja...@stimulussoft.com> wrote:
>>>
>>>       
>>>> Hi Everyone
>>>>
>>>> I am really struggling to use the Cayenne Modelling tool. It seems
>>>> whenever
>>>> I create an ObjectEntity from the DBEntity the relationships are not
>>>> always
>>>> propagated. This happens even when I follow the ARTIST tutorial. I tried
>>>> both Cayenne 3.0M6 and Cayenne 2.0.4 and the same behaviour is observed.
>>>> Is
>>>> this a known bug or am I likely doing something horribly wrong?
>>>>
>>>> Thank in advance
>>>>
>>>>
>>>> Jamie
>>>>
>>>>
>>>>
>>>>
>>>>         
>>     


-- 
Stimulus Software - MailArchiva
Email Archiving And Compliance
USA Tel: +1-713-343-8824 ext 100
UK Tel: +44-20-80991035 ext 100
Email:  jamie@stimulussoft.com
Web: http://www.mailarchiva.com
To receive MailArchiva Enterprise Edition product announcements, send a message to: <ma...@stimulussoft.com>


Re: Relationships Not Propagated

Posted by Michael Gentry <mg...@masslight.net>.
Just do:

partner.addToCustomers(customer);

You don't need to do both lines.  How did you create partner and
customer?  Did you create partner in a DataContext or fetch it from
the DB?  Is customer created in the same DataContext as partner?

mrg


On Fri, Sep 18, 2009 at 3:59 AM, Jamie <ja...@stimulussoft.com> wrote:
> Hi Michael
>
> Thanks for the help. Next question. I have a one to many Partner -> Customer
> relationship defined.
> When creating a new customer, I try to setup the relationship as follows:
>
>         partner.addToCustomers(customer);
>         customer.setPartner(partner);
>
> I get a NullPointer, even though customer and partner are not null.
>
> SEVERE: Servlet.service() for servlet jsp threw exception
> java.lang.NullPointerException
>   at
> org.apache.cayenne.CayenneDataObject.setReverseRelationship(CayenneDataObject.java:385)
>   at
> org.apache.cayenne.CayenneDataObject.setToOneTarget(CayenneDataObject.java:339)
>   at com.stimulus.support.auto._Customer.setPartner(_Customer.java:97)
>   at
> org.apache.jsp.customerdetail_jsp._jspService(customerdetail_jsp.java:94)
>   at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
>   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>   at
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
>   at
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
>   at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
>   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>   at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>   at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>   at
> org.apache.cayenne.conf.WebApplicationContextFilter.doFilter(WebApplicationContextFilter.java:91)
>   at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
>   at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>   at
> org.securityfilter.filter.SecurityFilter.doFilter(SecurityFilter.java:188)
>   at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
>   at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>   at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
>   at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
>   at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
>   at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>   at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>   at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
>   at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
>   at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
>   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
>   at java.lang.Thread.run(Thread.java:619)
>
> Any ideas?
>
> Jamie
>
> Michael Gentry wrote:
>>
>> When you create a brand new ObjEntity from a DBEntity, it propagates
>> all attributes and relationships defined in the DBEntity except for
>> the primary key (Cayenne Modeler assumes you don't need that exposed).
>>  Once you've created the ObjEntity, though, adding a new relationship
>> to the DBEntity will not be automatically synced to the ObjEntity.
>> You have to sync it manually (click the double-arrow icon in either
>> the DBEntity or ObjEntity toolbar or use the Project menu or keyboard
>> shortcut).  I'm talking mainly about 3.0M6 since I no longer use the
>> 2.x modeler and don't remember the exact specifics of how it behaves.
>>
>> mrg
>>
>>
>> On Thu, Sep 17, 2009 at 3:46 AM, Jamie <ja...@stimulussoft.com> wrote:
>>
>>>
>>> Hi Everyone
>>>
>>> I am really struggling to use the Cayenne Modelling tool. It seems
>>> whenever
>>> I create an ObjectEntity from the DBEntity the relationships are not
>>> always
>>> propagated. This happens even when I follow the ARTIST tutorial. I tried
>>> both Cayenne 3.0M6 and Cayenne 2.0.4 and the same behaviour is observed.
>>> Is
>>> this a known bug or am I likely doing something horribly wrong?
>>>
>>> Thank in advance
>>>
>>>
>>> Jamie
>>>
>>>
>>>
>>>
>
>

Re: Relationships Not Propagated

Posted by Jamie <ja...@stimulussoft.com>.
Hi Michael

Thanks for the help. Next question. I have a one to many Partner -> 
Customer relationship defined.
When creating a new customer, I try to setup the relationship as follows:

          partner.addToCustomers(customer);
          customer.setPartner(partner);

I get a NullPointer, even though customer and partner are not null.

SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
    at 
org.apache.cayenne.CayenneDataObject.setReverseRelationship(CayenneDataObject.java:385)
    at 
org.apache.cayenne.CayenneDataObject.setToOneTarget(CayenneDataObject.java:339)
    at com.stimulus.support.auto._Customer.setPartner(_Customer.java:97)
    at 
org.apache.jsp.customerdetail_jsp._jspService(customerdetail_jsp.java:94)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at 
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    at 
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at 
org.apache.cayenne.conf.WebApplicationContextFilter.doFilter(WebApplicationContextFilter.java:91)
    at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at 
org.securityfilter.filter.SecurityFilter.doFilter(SecurityFilter.java:188)
    at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
    at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at 
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
    at java.lang.Thread.run(Thread.java:619)

Any ideas?

Jamie

Michael Gentry wrote:
> When you create a brand new ObjEntity from a DBEntity, it propagates
> all attributes and relationships defined in the DBEntity except for
> the primary key (Cayenne Modeler assumes you don't need that exposed).
>  Once you've created the ObjEntity, though, adding a new relationship
> to the DBEntity will not be automatically synced to the ObjEntity.
> You have to sync it manually (click the double-arrow icon in either
> the DBEntity or ObjEntity toolbar or use the Project menu or keyboard
> shortcut).  I'm talking mainly about 3.0M6 since I no longer use the
> 2.x modeler and don't remember the exact specifics of how it behaves.
>
> mrg
>
>
> On Thu, Sep 17, 2009 at 3:46 AM, Jamie <ja...@stimulussoft.com> wrote:
>   
>> Hi Everyone
>>
>> I am really struggling to use the Cayenne Modelling tool. It seems whenever
>> I create an ObjectEntity from the DBEntity the relationships are not always
>> propagated. This happens even when I follow the ARTIST tutorial. I tried
>> both Cayenne 3.0M6 and Cayenne 2.0.4 and the same behaviour is observed. Is
>> this a known bug or am I likely doing something horribly wrong?
>>
>> Thank in advance
>>
>>
>> Jamie
>>
>>
>>
>>     


Re: Relationships Not Propagated

Posted by Michael Gentry <mg...@masslight.net>.
When you create a brand new ObjEntity from a DBEntity, it propagates
all attributes and relationships defined in the DBEntity except for
the primary key (Cayenne Modeler assumes you don't need that exposed).
 Once you've created the ObjEntity, though, adding a new relationship
to the DBEntity will not be automatically synced to the ObjEntity.
You have to sync it manually (click the double-arrow icon in either
the DBEntity or ObjEntity toolbar or use the Project menu or keyboard
shortcut).  I'm talking mainly about 3.0M6 since I no longer use the
2.x modeler and don't remember the exact specifics of how it behaves.

mrg


On Thu, Sep 17, 2009 at 3:46 AM, Jamie <ja...@stimulussoft.com> wrote:
> Hi Everyone
>
> I am really struggling to use the Cayenne Modelling tool. It seems whenever
> I create an ObjectEntity from the DBEntity the relationships are not always
> propagated. This happens even when I follow the ARTIST tutorial. I tried
> both Cayenne 3.0M6 and Cayenne 2.0.4 and the same behaviour is observed. Is
> this a known bug or am I likely doing something horribly wrong?
>
> Thank in advance
>
>
> Jamie
>
>
>