Coder Social home page Coder Social logo

jongo's People

Contributors

adutra avatar albertotn avatar apennebaker avatar bgranvea avatar bguerout avatar cdanger avatar ctrimble avatar dayde avatar dependabot[bot] avatar dwursteisen avatar edaubert avatar fixl avatar jblemee avatar jeanlaurent avatar jyemin avatar maximenowak avatar michel-kraemer avatar mjeanroy avatar olim7t avatar philleonard avatar sjoerdmulder avatar staticgears avatar sukrit007 avatar sumerjabri avatar swallez avatar techpavan avatar twillouer avatar xavier-calland avatar xhanin avatar yamsellem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jongo's Issues

Allow multiple documents versions to be unmarshalled into a POJO

Unknown properties can be handled with @JsonAnySetter (Jackson fallback annotation)

private static class BackwardFriend extends Friend {

        Date oldDate;

        @JsonAnySetter
        public void fallbackForBackwardCompatibility(String name, Object value) {
            if ("oldAddress".equals(name)) {
                setAddress((String) value);
            }
        }
    }

Nevertheless we should natively provide a way to adpat JSON before unmarshalling

(Un)Marshall BSON primitives using Java Driver

Given a POJO with a 'java.util.Date' attribute :
Jackson marshalls this attribute as a timestamp,
Field is persisted as a NumberLong into Mongo instead of ISODate

When dealing with pre-existing documents (ie. non persisted with Jongo), date are ISODate (eg. {$date:"2011-10-12T14:54:02.069Z"}) and Jackson is not able to unmarshall them.

This bug can occur on all BSON Primitives because (Un)Marshalling are fully delegated to Jackson.

All POJO ObjectId attributes are changed after a save operation

After a save operation, ObjectId generated by MongoDB is setted into POJO Object using reflection.
All POJO attributes are scanned and when an ObjectId type is found, we set it even if it doesn't represent document id.

We should finf way to only set document id....

Here is a failling test

   @Test
    public void shouldNotChangeOtherObjectIdField() throws IOException {

        ObjectId relationId = new ObjectId();
        LinkedFriend friend = new LinkedFriend(relationId);

        collection.save(friend);

        assertThat(friend.friendRelationId).isNotEqualTo(friend.getId()); //fail
        assertThat(friend.friendRelationId).isEqualTo(relationId);
    }

    private static class LinkedFriend extends Friend {

        private ObjectId friendRelationId;

        private LinkedFriend(ObjectId friendRelationId) {
            this.friendRelationId = friendRelationId;
        }
    }

ParameterBinder.countTokens doesnt work correctly with only "#"

I know this is not the most efficient way todo it but i want to update a complete document using:

collection.update("{ _id: # }", id).upsert().with("#", myObject);

This doesn't work but (" # ", myObject) does.

Possible feature: it would be nice to have a .with() which accepts a (T object) just as with .save()

named parameters

Supports named parameters , jpql example:
SELECT pub FROM Publisher pub WHERE pub.revenue>: rev

jongo :
friends.find("{name: #name, age: #age}")
.bind("name","John")
.bind("age",18)
;

Automatic partial loading

On find().as(MyObject.class) , Jongo should add partial fields based on MyObject fields.

On find().fields({xx}) .as(MyObject.class), Jongo should use json 'fields' value

Add logs

Few options:

  • slf4j
  • log4j
  • java.util.logging
  • LogListener (no logging API)

Allow a new (un)marshaller to be injected into jongo

(un)marshalling is based on two interfaces org.jongo.marshall.Unmarshaller and org.jongo.marshall.Marshaller

However, theses 2 interfaces don't explain clearly what a client have to implement to provide full compliant (un)marshallers
Example: Behind the scene, a Marshaller have to be able to serialize ObjectId...

Even if we do not change interfaces, we should provide a (un)marshalling compatibility test

@beatKyo is prototyping Gson (un)marshallers

Jongo breaks byte[] fields and produces incorrect json

Problem in two words: org.jongo.marshall.jackson.JacksonProcessor serializes any byte[] field as (without quotes) so it breaks data integrity and moreover produces invalid JSON.

Roots of the problem are located in org.jongo.marshall.jackson.NativeSerializer, and, deeply, in mongodb driver.

com.mongodb.util.JSONSerializers.LegacyBinarySerializer looks like:

    private static class LegacyBinarySerializer extends AbstractObjectSerializer {
        @Override
        public void serialize(Object obj, StringBuilder buf) {
            buf.append("<Binary Data>");
        }
    }

For more information, see https://groups.google.com/forum/?hl=fr&fromgroups#!topic/jongo-user/SjK1KwSErEs

Wrong (un)marshalling when ObjectId is not annotated with JSonProperty

As described in th documentation, a POJO with an ObjectId named '_id' doesn't need to be annotated with JSONProperty

Given a POJO :

    public static class User {
        private ObjectId _id;
        private String name;

        public ObjectId getId() {
            return id;
        }

        public void setId(ObjectId _id) {
            this.id = _id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }

Jackson handle '_id' and getId() as two different properties.
User is serialised as { "_id" : "4f92d1ae44ae2dac4527d49b" , "name" : "johnny" , "id" : { "$oid" : "4f92d1ae44ae2dac4527d49b"}}
During deserialization, Jackson sets '_id' property with ''_id" field and tries to set 'id' property using a new ObjectId()

Enhance Jackson customization

User should be able to reuse Jongo's jackson configuration.
An custom ObjectMapper can be injected into JacksonProcessor but it's a bit tricky to enhance configuration.

$group aggregate problem

Hi guys,

I receive this when working with aggregate:

{$group : {key: {topic:1, recipient:1},reduce: function(obj,prev){if(!obj.hasOwnProperty("topic")){prev.topic=obj.topic;prev.recipient=obj.recipient}}, initial: { } } } cannot be parsed

The same thing works perfectly well in the monogo console. That's why I think it might be an issue with Jongo. Any idea what's going on wrong here?

Update a document by ObjectId

Instead of

collection.update("{_id:#}", myId ).with("{$set:#}", pojo);

user should update a document without a parameterized query

collection.update(myId).with("{$set:#}", pojo);

Parameters can be non BSONPrimitive Objects

When parameters are binded into query, Jongo use native serialization feature ((ie; mongo java driver: Jongo.serialize()).

This serialization mechanism works well when parameters are BSON Primitives (List, String, int ...) but fail when parameter is a complex type :

collection.update('{}',{'$push:{value:#}},myBean)

User should be able to provide a custom behaviour to serialize his types.

MongoCollection is hard to mock

MongoCollection class is declared with a final keyword to prevent subclassing.
Nevertheless a final class can not be easily mocked (eg. with Mockito)

Here is few solutions :

  • Remove final keyword
  • Extract an interface
  • Remove final keyword and add a private constructor

Handle ObjectId in parameters

Mongo does not require entities to have ObjectId, _id property can be a simple String

A 0-dev solution should be to create a query with ObjectId

new Query.Builder("{_id:ObjectId(#)}").parameters(id);
new Query.Builder("{_id:#}").parameters(simpleId);

Grant access to raw JSON for some attributes

It's possible to ignore undesired properties of a document in a POJO. But, for every property manipulated, one must create a class with attribute (primitive or sub-class). It can be useful to access some property and sub-property as a raw object: an attribute containing a JSON object of every node and sub-nodes of a given node.

This stackoverflow question offers some clues on the matter.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.