cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Durchholz, Joachim" <Joachim.Durchh...@hennig-fahrzeugteile.de>
Subject RE: Some more concrete questions about Cayenne
Date Thu, 19 Jan 2012 13:55:39 GMT
> Here are a few answers.

Thanks!
Very much appreciated.

>> 1) Does anybody have concrete advice about using Cayenne without Modeler?
>>
>> Background:
>> I see Modeler is one of the major sources of "huh?" moments on the list.
>> It's an additional layer of abstraction between what Cayenne does and 
>>> what the developer sees, meaning it can introduce problems (and 
>> occasionally does); I'd want to get my feet wet with Cayenne without that complication.
>> I also see it's the one part that you actually can avoid using - the 
>> XML can be edited by hand.
> 
> I don't see this as reducing complexity, rather it increases it since the
> tool is much easier to use and understand than an XML file.

Hm... well, Modeler adds a level of interpretation (if only implicitly) between user and XML.
For example, that "To Dep PK" checkbox doesn't sound quite self-explanatory.

Of course, it essentially depends on what's better documented: the XML or Modeler :-)

>  Having a model representation that is separate from the java files
> (i.e. not using embedded java annotations) is a big strength for Cayenne
> compared to Hibernate/JPA.

I see it the other way round: if the Java code and the specifications that it depends on are
in the same file, it's easier to spot problems.
Of course, if the Java code in question is generated anyway, the question is moot.

>  The tool makes it both easier and better.

Noted. Thanks.


> Now the potential problems I see with hand-editing the XML:
>
> 1a) Is there a DTD? Without a DTD, hand editing becomes too cumbersome 
> and error-prone.

There is a schema:

<?xml version="1.0" encoding="utf-8"?>

<data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://cayenne.apache.org/schema/3.0/modelMap
http://cayenne.apache.org/schema/3.0/modelMap.xsd" project-version="6">

Sweet :-)

>> 1b) Does Cayenne offer a way to check consistency between XML and a 
>> database?
> 
> Yes

Just through modeler, or is it available through an Ant task or its Maven equivalent?
Half a bonus point if it's in the Cayenne runtime jars since it would save me a configuration
step :-)

>> 2) How would one assign a "field type" with a field in a Cayenne Pojo?
> 
> The objects in the data map (entites, attributes, etc) aren't extensible
> with arbitrary data currently (webobjects has this with the userInfo
> dictionary / hashmap).

I guess I'll go with the _Entity/Entity split then.
It's not a very big deal anyway.

>> 2d) Anything I haven't thought of. Different ways to use Java 
>> reflection, a Modeler option I'm not aware of that does all these 
>> things out of the box, whatever.
> 
> I'm not sure what you're trying to achieve here.

Just exploring possibilities.
Delegation would give me more independence from the generated code, at the expense of some
memory usage (which could become relevant since some of the things we do are bulk operations
on hundreds of thousands of objects; some of the operations haven't been split into reasonably-sized
auto-continuing transactions yet).

>  Do you want to isolate Cayenne so that it is not "polluting" your business objects?

That is a factor in the back of my mind, but I think that can be handled using private fields
and protected getters/setters and should not become a problem.

> Regardless, you will want to use Cayenne's code generation.  The
> templates are totally configurable so you can make it do whatever
> you like.

I'm extremely wary of modifying templates. It means I have to revisit them on each and every
Cayenne update to see whether the basic machinery has changed and I need to redo my modifications.

Also, for some reason, templates tend to be hard to modify.
I tend to whince whenever I hear the word :-)
I don't know how it is for Cayenne though; among the problems I have seen elsewhere are:
- 

> The code generation is available via Modeler, ant, or the eclipse plugin.

That's very good.

Regards & thanks,
Jo

Mime
View raw message