Gary Jarrel | 5 Jul 08:44 2010
Picon

XMLEncoder / XMLDecoder

Hi All

Am I able to use the XMLEncoder to serialize a list of data objects. I
can see the XMLDecoder has a decodeList method, however the XMLEncoder
does not appear to have a public encodeList method?

Thank you

Gary

Andrus Adamchik | 5 Jul 09:04 2010

Re: XMLEncoder / XMLDecoder

I can see our unit tests have a collection encoding example:

List<TestObject> dataObjects = new ArrayList<TestObject>();

dataObjects.add(new TestObject("George", 5, true));
dataObjects.add(new TestObject("Mary", 28, false));
dataObjects.add(new TestObject("Joe", 31, true));

String xml = new XMLEncoder().encode("EncodedTestList", dataObjects);

On a side note, I am not a big fan of our XML coding implementation.  
It is DOM based and is not very scaleable. I started writing an  
XStream-based replacement in sandbox:

* http://svn.apache.org/viewvc/cayenne/sandbox/cayenne-serialization/?pathrev=814869
* http://markmail.org/message/ljngasncx6jur6ud

But then my own itch to solve it disappeared, so that was put on hold.  
IIRC it is usable for most object subgraphs, but not optimized for all  
scenarios.

Andrus

On Jul 5, 2010, at 9:44 AM, Gary Jarrel wrote:
> Hi All
>
> Am I able to use the XMLEncoder to serialize a list of data objects. I
> can see the XMLDecoder has a decodeList method, however the XMLEncoder
> does not appear to have a public encodeList method?
>
(Continue reading)

Gary Jarrel | 5 Jul 09:39 2010
Picon

Re: XMLEncoder / XMLDecoder

On Mon, Jul 5, 2010 at 5:04 PM, Andrus Adamchik <andrus <at> objectstyle.org> wrote:

> On a side note, I am not a big fan of our XML coding implementation. It is
> DOM based and is not very scaleable. I started writing an XStream-based
> replacement in sandbox:
>
> *
> http://svn.apache.org/viewvc/cayenne/sandbox/cayenne-serialization/?pathrev=814869
> * http://markmail.org/message/ljngasncx6jur6ud
>
> But then my own itch to solve it disappeared, so that was put on hold. IIRC
> it is usable for most object subgraphs, but not optimized for all scenarios.
>

I've been looking at using XSteam as well, seems interesting, however
I have a need to serialize only a small number of objects so perhaps
the current implementation would do the trick as well. XStream seems
quite easy to use, may give it a god just for the fun of it.

If I have decoded an object from XML is there an automated way to tell
that the decoded object has a representing record in the database.
Just having a look all the objects after being decoded have NEW as a
Persistence State. I tried to also serialize the primary key during
the serialization process, but when decoding it, it still has
persistence state new.

Thank you

Gary

(Continue reading)

Andrus Adamchik | 5 Jul 09:46 2010

Re: XMLEncoder / XMLDecoder

In the old implementation I am pretty sure there's no notion of object  
states stored in XML.

In the one I haven't got there just yet, concentrating on serializing  
committed objects.

Andrus

On Jul 5, 2010, at 10:39 AM, Gary Jarrel wrote:

> On Mon, Jul 5, 2010 at 5:04 PM, Andrus Adamchik <andrus <at> objectstyle.org 
> > wrote:
>
>> On a side note, I am not a big fan of our XML coding  
>> implementation. It is
>> DOM based and is not very scaleable. I started writing an XStream- 
>> based
>> replacement in sandbox:
>>
>> *
>> http://svn.apache.org/viewvc/cayenne/sandbox/cayenne-serialization/?pathrev=814869
>> * http://markmail.org/message/ljngasncx6jur6ud
>>
>> But then my own itch to solve it disappeared, so that was put on  
>> hold. IIRC
>> it is usable for most object subgraphs, but not optimized for all  
>> scenarios.
>>
>
> I've been looking at using XSteam as well, seems interesting, however
(Continue reading)

Juan José Gil | 7 Jul 04:01 2010
Picon

Mapping views with modeller

Hi all, I looked at modeller doc and googled but didn't find out how to map a 
view with cayenne modeler.

Is it possible? 

Or I need to map views manually? In such case, were can I find info on how to 
do this mapping?

Thanks for your time and awesome framework!

Regards,
matero

Andrus Adamchik | 7 Jul 09:58 2010

Re: Mapping views with modeller

Yes, it is possible. From Cayenne perspective a view is no different  
than a table. So a DbEntity needs to be created for a view, and mapped  
to ObjEntity,

Andrus

On Jul 7, 2010, at 5:01 AM, Juan José Gil wrote:

> Hi all, I looked at modeller doc and googled but didn't find out how  
> to map a
> view with cayenne modeler.
>
> Is it possible?
>
> Or I need to map views manually? In such case, were can I find info  
> on how to
> do this mapping?
>
> Thanks for your time and awesome framework!
>
> Regards,
> matero
>

matero | 7 Jul 15:48 2010
Picon

Re: Re: Mapping views with modeller

Thanks Andrus.

So, to map a view, I need to  create it on my DB, then import it with the
modeler and then map it.
Or I should create the DbEntity as a normal one (putting all its attributes as
read-only) ?

Is it possible from the meta-model maintained by cayenne determine if an
ObjEntity maps a table or a view? this could be used to define which class
extend in the velocity template avoiding update / insert operations.
If it is not possible, then I should used some kind of convention on
tables/views names but I prefer to use the cayenne meta-model.

Finally, is there a way to tell the modeler "don't try to assign a PK to this
kind of entity" (in hibernate there is a "assigned id" strategy whih does this).

Sorry for my poor english and to bother you with this questions.
Thanks in advance.

Regards
matero

Gary Jarrel | 8 Jul 02:44 2010
Picon

Re: Re: Mapping views with modeller

On Wed, Jul 7, 2010 at 11:48 PM, matero <matero <at> gmail.com> wrote:
> Thanks Andrus.
>
> So, to map a view, I need to  create it on my DB, then import it with the
> modeler and then map it.
> Or I should create the DbEntity as a normal one (putting all its attributes as
> read-only) ?

If you have a view in the database you can reverse engineer it into
the Cayenne Modeler and the modeler will create both the DB and the
OBJ entities for you. Alternatively you can do the whole process
manually by creating a db entity having the same name as your view and
then map each attribute in the modeler to the respective attribute in
the view. Then you create your object entity and map it to the
database entity via the Table/View option and then you can sync the
object entity so that it picks up all the fields from the view.

> Is it possible from the meta-model maintained by cayenne determine if an
> ObjEntity maps a table or a view? this could be used to define which class
> extend in the velocity template avoiding update / insert operations.
> If it is not possible, then I should used some kind of convention on
> tables/views names but I prefer to use the cayenne meta-model.

Not all views are read only, we commonly use views to update things in
the database (but not all database would support updating through
views) however any object entity can me made a "Read Only" entity by
specifying that it's "Read Only" in the modeler. And in this instance
the class generator (which uses velocity templates) will not generate
the setter methods.

(Continue reading)

Andrus Adamchik | 8 Jul 09:29 2010

Cayenne 3.0 in the Media

We got some press:

http://www.developer.com/features/article.php/3891766/Apache-Cayenne-3-Delivers-New-Features-for-Java-ORM.htm

and some blogs:

https://blogs.apache.org/foundation/entry/apache_cayenne_v_3_0

Cheers,
Andrus

---------------
Andrus Adamchik
Apache Cayenne ORM: http://cayenne.apache.org/
Twitter: http://twitter.com/andrus_a

Juan José Gil | 8 Jul 13:20 2010
Picon

Re: Re: Mapping views with modeller

Gary, thanks for your aclarations, they cleared mi mind...
after I let my questions out I find some of the answers (like the read-only
objects) myself...
I should learn to do less questions and more reading :(

I expect to return something to cayenne some day :)

regards
Juanjo

2010/7/7 Gary Jarrel <garyjarrel <at> gmail.com>

> On Wed, Jul 7, 2010 at 11:48 PM, matero <matero <at> gmail.com> wrote:
> > Thanks Andrus.
> >
> > So, to map a view, I need to  create it on my DB, then import it with the
> > modeler and then map it.
> > Or I should create the DbEntity as a normal one (putting all its
> attributes as
> > read-only) ?
>
> If you have a view in the database you can reverse engineer it into
> the Cayenne Modeler and the modeler will create both the DB and the
> OBJ entities for you. Alternatively you can do the whole process
> manually by creating a db entity having the same name as your view and
> then map each attribute in the modeler to the respective attribute in
> the view. Then you create your object entity and map it to the
> database entity via the Table/View option and then you can sync the
> object entity so that it picks up all the fields from the view.
>
(Continue reading)


Gmane