Comments (2)
Hi Andy,
I believe what you actually want to do here is break apart an object graph for persistence into separate collections?
I would suggest doing this instead using a parent id that references the top level object in the children, and then use SalatDAO with ChildCollection to break apart the object when you persist it and re-assemble it when you deserialize it. See the salat specs on the dao and child collections in salat-core.
I don't plan to support passing in a custom serializer as you propose at present (leaving aside the problem that custom serialization and deserialization must be paired or deserialization will fail), although future versions might allow you to define custom transformations for global types (like, say, java.net.URI).
from salat.
Hi Rose,
Thanks you, I've just adapt my model to use what you told me. Which works pretty well indead.
But still that it would be interesting to have such back and forth marshalling to handle objects graph splitted into several collections.
'Cause now, I've introduced some ObjectId as parameter of my case class, with lazy val that retrieves the orignial object. That fits the need but polute a little bit the model? Don't you think?
However, couldn't we have special behavior for ObjectId, Collection of ObjectId and Map valued by ObjectId fields ? By using an annotation for instance (I'm writing while thinking, sorry if it's dumb) like the following
case class Person(name:String, @listref[AddressDAO, "_id"] addresses:List[Address]) {}
This will store the _id of addresses as a mondgo db list.
Just my 0.02c
from salat.
Related Issues (20)
- Custom TypeHint strategy for JSON HOT 2
- Unable to serialize case class hierarchy HOT 3
- mongo connection leak - re-use one mongo connection for each test DAO to reduce connection footprint. HOT 2
- Update Casbah to 2.8.2 in Salat 1.10.x to support connecting to Mongo 3.x server. HOT 16
- Play Salat HOT 4
- Project status update? HOT 23
- java.lang.ClassCastException when deserializing from Salat in context of akka runtime. HOT 4
- Error with reason "Very strange!" - GRATER GLITCH HOT 2
- Upgrade to sbt 0.13.12
- Release Salat 1.10 HOT 1
- JSON data can deserialize into collections containing data not matching the container generic type.
- More specific error class for Grater errors: SalatDeserializationException
- Release 1.11.x with Casbah 3.1.1 support (but not Scala 2.12) HOT 18
- Will this work with the latest Casbah 3.1.1? HOT 1
- SalatDAO support for collections HOT 7
- Scala 2.12 HOT 8
- Optional field in MongoDBObject with null value causing MatchError HOT 11
- Custom Transformers never get applied to case classes HOT 9
- Case class not serialising in order HOT 3
- Support for Mongo 3.6+ HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from salat.