BTW, the code I posted only does database runtime relationships, not Java
object relationships, plus it handles compound keys poorly, so there is
room for improvement!  :-)

Thanks,

mrg


On Thu, Mar 17, 2016 at 10:52 AM, Michael Gentry <blackn...@gmail.com>
wrote:

> Hi Frank,
>
> You can try adding/calling this to print them:
>
> import org.apache.cayenne.map.DbEntity;
> import org.apache.cayenne.map.DbJoin;
> import org.apache.cayenne.map.DbRelationship;
>
> ...
>
>     public static void dumpRuntimeRelationships(ObjectContext
> objectContext)
>     {
>         for (DbEntity entity :
> objectContext.getEntityResolver().getDbEntities())
>         {
>             StringBuilder builder = new StringBuilder();
>
>             for (DbRelationship relationship : entity.getRelationships())
>             {
>                 if
> (relationship.getName().startsWith("runtimeRelationship"))
>                 {
>                     builder.append("    Name: ");
>                     builder.append(relationship.getName());
>                     builder.append(", Source: ");
>
> builder.append(relationship.getSourceEntity().getName());
>                     builder.append(", Target: ");
>
> builder.append(relationship.getTargetEntity().getName());
>                     builder.append(", Joins: ");
>
>                     for (DbJoin join : relationship.getJoins())
>                     {
>                         builder.append(join.getSourceName());
>                         builder.append(" : ");
>                         builder.append(join.getTargetName());
>                     }
>
>                     builder.append("\n");
>                 }
>             }
>
>             if (builder.length() > 0)
>             {
>                 builder.insert(0, "\n");
>                 builder.insert(0, entity.getName());
>                 builder.insert(0, "\nEntity: ");
>
>                 System.out.println(builder);
>             }
>         }
>     }
>
>
> Example output:
>
> Entity: s_budget_years
>     Name: runtimeRelationship18, Source: s_budget_years, Target:
> p_line_items, Joins: pk : delta_quantity_fk
>     Name: runtimeRelationship19, Source: s_budget_years, Target:
> p_line_items, Joins: pk : delta_total_cost_fk
>
>
>
> mrg
>
> PS. The "source" info is a bit redundant, but will copy/paste well if you
> need to send to someone.
>
>
>
> On Thu, Mar 17, 2016 at 10:17 AM, Frank Herrmann <
> frank.herrm...@modernizingmedicine.com> wrote:
>
>> Thanks everyone. We were able to pepper some temporary logging in the code
>> and figure out the relationship. I appreciate all the quick responses.
>>
>> -Frank
>>
>> On Thu, Mar 17, 2016 at 10:12 AM, Michael Gentry <blackn...@gmail.com>
>> wrote:
>>
>> > Hi Jurgen,
>> >
>> > Maybe you are seeing something different than me?  When I have logging
>> > turned on, I see things like:
>> >
>> > org.apache.cayenne.map.EntityResolver added runtime complimentary
>> > DbRelationship from s_budget_years to p_line_items
>> > ...
>> > org.apache.cayenne.map.EntityResolver added runtime complimentary
>> > ObjRelationship from BudgetYears to LineItem
>> >
>> > It doesn't specify the relationship name, though.
>> >
>> > mrg
>> >
>> >
>> > On Thu, Mar 17, 2016 at 9:30 AM, <do...@xsinet.co.za> wrote:
>> >
>> > >
>> > >
>> > > Hi Frank
>> > >
>> > > Cayenne logs the runtime relationships it generates when it loads the
>> > > model into memory.
>> > >
>> > > So if you look in the log which it also sends to System.err and search
>> > > for "runtimeRelationship725" then you will be able to see which entity
>> > > it's associated with. At least then he'll have a clue as where to
>> begin
>> > > looking.
>> > >
>> > > Regards
>> > >
>> > > Jurgen
>> > >
>> > > On 2016-03-17 15:02, Frank Herrmann wrote:
>> > >
>> > > > Thanks. I passed this along to the developer. We are using version
>> 3.1.
>> > > >
>> > > > On Wed, Mar 16, 2016 at 6:29 PM, Michael Gentry <
>> mgen...@masslight.net
>> > >
>> > > > wrote:
>> > > > Hi Frank, I don't have any handy code to do this at the moment, but
>> the
>> > > approach I would take is to write a utility method to dump the model's
>> > > source/destination relationship information immediately after loading
>> the
>> > > model into memory. Then, when you get the validation exception, you
>> can
>> > > reference that data dump for assistance. mrg PS. What version of
>> Cayenne?
>> > > On Wed, Mar 16, 2016 at 3:12 PM, Frank Herrmann <
>> > > frank.herrm...@modernizingmedicine.com> wrote: Hello all, We have a
>> > > developer here that recently asked for my help and told him I'd reach
>> > out.
>> > > He is getting a validation failure error on a runtime relationship
>> > > (specifically runtimeRelationship725). As these are created during
>> > runtime,
>> > > he is setting a break point in the code at the commit to try and
>> figure
>> > out
>> > > what object this runtime relationship is attached to. My question is,
>> is
>> > > there an easy way to pinpoint what object this relationship is
>> attached
>> > to,
>> > > or what relationship it is reversing so he can troubleshoot the
>> > > validation error? Thanks, -Frank -- FRANK HERRMANN SOFTWARE ENGINEER
>> T:
>> > 561-880-2998
>> > > x1563 E: frank.herrm...@modmed.com [image: [ Modernizing Medicine ]]
>> <
>> > > http://www.modmed.com/ [1]> [image: [ Facebook ]] <
>> > > http://www.facebook.com/modernizingmedicine [2]> [image: [ LinkedIn
>> ]] <
>> > > http://www.linkedin.com/company/modernizing-medicine/ [3]> [image: [
>> > > YouTube ]] <http://www.youtube.com/user/modernizingmedicine [4]>
>> [image:
>> > > [ Twitter ]] <https://twitter.com/modmed_EMA [5]> [image: [ Blog ]] <
>> > > http://www.modmed.com/BlogBeyondEMR [6]> [image: [ Instagram ]] <
>> > > http://instagram.com/modernizing_medicine [7]>
>> > >
>> > > --
>> > > FRANK HERRMANN
>> > > SOFTWARE ENGINEER
>> > >
>> > > T: 561-880-2998 x1563
>> > >
>> > > E: frank.herrm...@modmed.com
>> > >
>> > > [image: [ Modernizing Medicine ]] <http://www.modmed.com/ [1]>
>> > > [image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine
>> [2]>
>> > > [image:
>> > > [ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/
>> > > [3]> [image:
>> > > [ YouTube ]] <http://www.youtube.com/user/modernizingmedicine [4]>
>> > > [image: [
>> > > Twitter ]] <https://twitter.com/modmed_EMA [5]> [image: [ Blog ]]
>> > > <http://www.modmed.com/BlogBeyondEMR [6]> [image: [ Instagram ]]
>> > > <http://instagram.com/modernizing_medicine [7]>
>> > >
>> > >
>> > >
>> > > Links:
>> > > ------
>> > > [1] http://www.modmed.com/
>> > > [2] http://www.facebook.com/modernizingmedicine
>> > > [3] http://www.linkedin.com/company/modernizing-medicine/
>> > > [4] http://www.youtube.com/user/modernizingmedicine
>> > > [5] https://twitter.com/modmed_EMA
>> > > [6] http://www.modmed.com/BlogBeyondEMR
>> > > [7] http://instagram.com/modernizing_medicine
>> > >
>> >
>>
>>
>>
>> --
>> FRANK HERRMANN
>> SOFTWARE ENGINEER
>>
>> T: 561-880-2998 x1563
>>
>> E: frank.herrm...@modmed.com
>>
>>
>>
>> [image: [ Modernizing Medicine ]] <http://www.modmed.com/>
>> [image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine>
>> [image:
>> [ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/>
>> [image:
>> [ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
>> Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
>> <http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
>> <http://instagram.com/modernizing_medicine>
>>
>
>

Reply via email to