Am 28.06.11 16:41, schrieb oceanfront:
> I've been mucking about with grails-jaxrs for a few days now. Very
> cool!
Great, thanks for trying it!
> I managed to get createdDate and lastUpdated stuff working so that PUT
> works.
Great! This is definitely something that is painfully missing in the
plugin. Would be great if you could share some code snippets or provide
a patch (clone -> change -> pull request).
I also thought about adding support for If-modified-since or
Last-modified headers but ... no time so far ...
> I'm now exploring a project which has a master-detail (one to many)
> relationship.
> When I request the master record, I get the IDs of the child records.
> (shallow copy).
> Is there a simple way to get a deep copy, or would a custom provider
> be needed?
You'll need a custom provider at the moment.
> Further to this, what is the recommended way to POST new master detail
> records? Can this be done with a single POST (to make it
> transactional) or should the master record get POSTed first, and then
> the detail records?
Currently yes. Otherwise you'll need a custom provider as well.
> If there is a way to make a single POST work, I'd be happy to
> contribute the project as a sample.
I'd love to see a contribution for that (also for deep copies when
GETting records). Let me know if you need further help.
Cheers,
Martin
> Thanks!
>
>
--
Martin Krasser
blog: http://krasserm.blogspot.com
code: http://github.com/krasserm
twitter: http://twitter.com/mrt1nz
To get a deep clone on GET, simply add:grails.converters.json.default.deep=true
grails.converters.xml.default.deep=true
to Config.groovy. This results in xml with a deep copy.
If I try to post the copy back (after removing ids) I get a"Provided id of the wrong type for class" exception for the detail class.
I suspect if I can figure out why this is happening, it (POST) may work as is. GORM is supposed to be able to figure out the back references from detail to master.
If you'd like, I can zip this up and send it. (stuck in the airport..)
Could this be related to string vs longin DomainObjectReaderSupport class?
PS As for the date stuff, it needs to be added at the project level. As soon as I'm back in the office I can document it for you. (it's in another project)
To get a deep clone on GET, simply add:
grails.converters.json.default.deep=true
grails.converters.xml.default.deep=true
to Config.groovy. This results in xml with a deep copy.
If I try to post the copy back (after removing ids) I get a"Provided id of the wrong type for class" exception for the detail class.
I suspect if I can figure out why this is happening, it (POST) may work as is. GORM is supposed to be able to figure out the back references from detail to master.
If you'd like, I can zip this up and send it. (stuck in the airport..)
Could this be related to string vs longin DomainObjectReaderSupport class?
To get a deep clone on GET, simply add: