On Tue, Nov 13, 2018 at 11:34 AM Alexander Petrossian (PAF) <
[email protected]> wrote:

> вт, 13 нояб. 2018 г. в 20:02, Giaccone, Tony <[email protected]
> >:
>
> > This is going to be a pretty big task, because of the number of tables no
> > matter what you do. Is the problem that there are no foreign key
> > relationships between your tables?
> >
>
> Yep. This is my primary problem. No doc/FK/relationships in cayenne
> mappings.
> Guys only did hundreds of queries.
>
>
> > If you have the mapping file, you can always open that map with the
> Cayenne
> > Modeler. It with that you can generate all the SQL for all the schema, of
> > your database. You can even create a diagram of the database and the
> > relationships between the tables using the Cayenne Modeler.
>
>
> Can't do that. There are no relationships defined in mapping files ;)
>
>
> > If you have the java classes that the modeler creates, you can also start
> > looking in the java class files for the relationships between the
> objects.
> >
>
> If there were no relationships defined inside mapping files I feel there
> would be nothing defined in code?
>
>
> > Again a daunting task, but certainly possible.  I'm sure you can find a
> > java tool, maybe class-visualizer, to document the relationships between
> > the objects.
> >
>
> I have no access to source code, but one can reverse .class files, I guess.
> Haven't tried that yet. Thanks for the pointer.
>
>
> > If you don't have a mapping file with classes, but and just have a huge
> map
> > with many sql statements in it, you could always pull them out of the map
> > directly.
> >
>
> Tony, as I've indicated, I can give SQL statements to analyser (part of
> jailer, done with JSQLParser project).
> But I have hard time fighting with SQL templates.
> Maybe there is some easy [ ;) ] way to ask Cayenne to explode all those
> templates for me?
> remove #result, solve all #chain and #chunk and do #ifs (all via true side)
> and anything else I forgot here.
> I need "some valid SQL" queries.
>

I think your best path forward would be to use an XML parser to pull out
SQL Templates from the .map.xml and then use Regular Expressions to replace
the Velocity template commands (#if, etc) with whatever you want.


>
> Alexander
>
> > https://github.com/JSQLParser/JSqlParser/issues/710
> > https://sourceforge.net/p/jailer/feature-requests/52/
>
>
>
>
> > Tony
> >
> > On Tue, Nov 13, 2018 at 3:25 AM Alexander Petrossian (PAF) <
> > [email protected]> wrote:
> >
> > > Friends, please share your vision.
> > >
> > > I got a project with lots of Apache Cayenne mappings (2.0), and
> database
> > is
> > > not documented at all.
> > >
> > > All insights about links between tables (about 2 thousands of tables) I
> > can
> > > get is only from queries found in Cayenne mappings (several megabytes
> of
> > > those).
> > >
> > > Those tables I can quick analyse with JSQLParser. But it needs raw
> SQLs.
> > >
> > > Question: Is there some easy way to programmatically iterate through
> all
> > > queries and apply templates to get those raw SQLs?
> > >
> > > (Any hints would be very appreciated!)
> > >
> > >
> > >
> > > https://github.com/JSQLParser/JSqlParser/issues/710
> > >
> > > https://sourceforge.net/p/jailer/feature-requests/52/
> > >
> > > --
> > > PAF
> > >
> > > P.S. tried to discuss it here first:
> > > https://jira.apache.org/jira/browse/CAY-2495
> > >
> >
>
>
> --
> PAF
>

Reply via email to