spring-attic / grails-data-mapping Goto Github PK
View Code? Open in Web Editor NEWGrails Data Mapping Project
License: Apache License 2.0
Grails Data Mapping Project
License: Apache License 2.0
Currently domain properties of type Date can't have null values . Since all date values are converted into long before being persisted to neo4j and neo4j doesn't allow nulls for primitives.
A workaround to initalize every date object as
new Date(0l),
however this can be easily changed in DateToLongConvertor and check for null dates and perhaps store it as 0l if date is null.
Amad
Log4j with the Neo4j-Grails plugin seems to be duplicating log4j and it is getting confused:
I have tried this with the sample application and my own application. I am using:
Neo4j kernel 1.8.1
Grails 1.3.7 and Grails 2.2.1
class A
{
static mapWith = "neo4j"
A parent
String desc
}
Creating two instances of A (a1 and a2) and setting one of them as the others parent (a2 ---parent--> a1) ends up creating a loop after the call to Neo4jSession.persist() on a2 (i.e. (a1) ---parent--> (a2) and (a2) ---parent--> (a1)).
I would investigate further but I am unable to find a .jar with sources to attach into my project in Intellij IDEA, and downloading from GitHub and attaching is not working either (maybe because they're Groovy source files).
Edit: I'm using Grails 2.0.4 and gorm-neo4j M13.
Edit2: Apparently this issue is not in gorm-neo4j itself, as after some testing I cannot reproduce it using "standard" domain classes. We are, however, experimenting with the concept of dynamically creating domain classes on runtime, and it seems to cause this specific issue.
Grails 2.1.3
org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type java.lang.Long for value 'test1'; nested exception is java.lang.IllegalArgumentException: java.lang.NumberFormatException: For input string: "test1"
at org.grails.datastore.mapping.model.types.conversion.DefaultConversionService.convert(DefaultConversionService.java:18)
at org.grails.datastore.mapping.redis.engine.RedisEntityPersister.convertToNativeKey(RedisEntityPersister.java:147)
at org.grails.datastore.mapping.engine.NativeEntryEntityPersister.retrieveEntity(NativeEntryEntityPersister.java:309)
package org.redis.grails.plugin
import grails.plugin.databasesession.InvalidatedSessionException
class RedisPersistentSession {
static mapWith = "redis"
String id
Long creationTime
Long lastAccessedTime
Boolean invalidated = false
Integer maxInactiveInterval = 30
static transients = ['valid']
static mapping = {
id generator: 'assigned', type: "string"
version false
dynamicUpdate true
}
}
We are editing domain objects through a controller method, which in terns calls a service method to actually perform validate and save.
The service method throws a ValidationException (Runtime) when validation fails, however the changes are always reflected in neo4j database after controller returns.
Attached is a simple app, using controller action create and edit domains and you can reproduce the error.
How do you use disjunction in DetachedCriteria?
I've tried:
def c = new DetachedCriteria(A).build {
eq('name' , '1')
or {
like('name', '2')
}
}
and:
def c = new DetachedCriteria(A).build {
eq('name' , '1')
}
c.or { like('name', '2') }
And the query sent to the database are:
........ where this_.name in (?) and (this_.name like ?)
They were joined by 'and' instead of 'or'
Properties with Date data type should be persisted as primitive longs rather than Strings.
They are converted to millisecs and stored and converted to and from from the datastore perfectly. However, they are stored as strings rather than a primitive long. It would be better if they are stored as longs - this would permit date comparison and calculations from cypher queries.
Extracted from a message I've sent to the Grails-users mailing list:
After I replaced my Java class for dealing with MongoDB with the mongodb plugin I am now experiencing some problems on Grails 2 in development mode.
I have two after filters that will be saving data in the database. One of the filters is saving a log entry in the MongoDB database while the other is saving an entry in the hibernate database.
After I changed a controller in development mode I get this message:
"No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here"
It doesn't happen always, but if I restart the server it will work again.
But if I change some domain class, I'll get this:
"Join queries are not supported by MongoDB"
But the stacktrace will show that it is trying to connect to the database configured by Hibernate using the mongodb session...
The message is not always the same when I change some domain class. Sometimes I get this:
"No Datastore Session bound to thread, and configuration does not allow creation of non-transactional one here"
Hi,
I've started to evaluate Neo4j for a grails project of mine. However, I am struggeling to find the right starting points (outdated neo4j plugin, spring data, grails-data-mapping?). I'd like to use grails-data-mapping due to the up-to-date neo4j install and the GORM support, but I can't find any references of how to create a domain class to use as a relationship that contains attributes (such as the classical weight attribute seen in graphs). Any pointers?
For example, I'd like to have an Annotation relationship with a time attribute to model the relationship between a Video and a Person.
BTW, not sure if this is the best place to discuss this, pls point me to any alternative that I missed!
Greetings,
Nils
http://twitter4j.org/maven2/org/grails/grails-datastore-gorm-neo4j/1.0.0.RC3/grails-datastore-gorm-neo4j-1.0.0.RC3.pom
-- artifact org.grails#grails-datastore-gorm-neo4j;1.0.0.RC3!grails-datastore-gorm-neo4j.jar:
http://twitter4j.org/maven2/org/grails/grails-datastore-gorm-neo4j/1.0.0.RC3/grails-datastore-gorm-neo4j-1.0.0.RC3.jar
::::::::::::::::::::::::::::::::::::::::::::::
:: UNRESOLVED DEPENDENCIES ::
::::::::::::::::::::::::::::::::::::::::::::::
:: org.grails#grails-datastore-gorm-neo4j;1.0.0.RC3: not found
::::::::::::::::::::::::::::::::::::::::::::::
I tried with "compile ":neo4j:1.0-SNAPSHOT" and also with "compile ":neo4j:latest.version"
Both show the same error as above.
Thanks
Mark
Implement CouchDB support in Grails Data Mapping using the Ektorp library (https://github.com/helun/Ektorp).
Attempted to use 1.3.7 Grails w/ the Ne04j plugin. Needed to remove the Spock 0.6 plugin in order to get it to compile.
Should there be a way to disable the signing plugin for local builds? The 'install' task is label as a way to install code into the local repository.. Anyway getting a failure attempting to just build w/o going through gpg..
Workaround:
A query of the form,
def user = User.get(7) //example
def c = User.createCriteria()
c.list {
'in'('friends', [user])
}
executes, but does not return any results. The equivalent cypher query would be something like,
start n=node(7) match n<-[:friends]-u return u" (node(7) is 'user')
Hi,
My app get stuck in a loop when I try to save an object with some HashMap attribute.
Thank you!
Build scripts are broken.
I followed the getting started page at:
http://springsource.github.com/grails-data-mapping/manual/guide/2.%20Getting%20Started.html
did the git clone:
git clone [email protected]:SpringSource/grails-data-mapping.git
executed the build line:
./gradlew idea
and it fails.
I have the latest gradle, groovy, grails and maven installed.
What am I doing wrong?
below is a summary of the failure followed by a clip from the console:
FAILURE: Build failed with an exception.
Execution failed for task ':grails-datastore-gorm-dynamodb:ideaModule'.
Could not resolve all dependencies for configuration 'detachedConfiguration4'.
Module version
group:org.grails, module:grails-datastore-gorm-dynamodb, version:0.1.2.BUILD-SNAPSHOT,
configuration:detachedConfiguration4 declares a dependency on configuration 'signatures' which is not declared in the module descriptor for
group:org.grails, module:grails-datastore-gorm, version:2.0.0.BUILD-SNAPSHOT
17:00:00.522 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':grails-datastore-gorm-dynamodb:ideaModule'
17:00:00.522 [LIFECYCLE] [org.gradle.TaskExecutionLogger] :grails-datastore-gorm-dynamodb:ideaModule FAILED
17:00:00.528 [ERROR] [org.gradle.BuildExceptionReporter]
17:00:00.528 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
17:00:00.528 [ERROR] [org.gradle.BuildExceptionReporter]
17:00:00.529 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
17:00:00.529 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':grails-datastore-gorm-dynamodb:ideaModule'.
17:00:00.529 [ERROR] [org.gradle.BuildExceptionReporter] > Could not resolve all dependencies for configuration 'detachedConfiguration4'.
17:00:00.529 [ERROR] [org.gradle.BuildExceptionReporter] > Module version group:org.grails, module:grails-datastore-gorm-dynamodb, version:0.1.2.BUILD-SNAPSHOT, configuration:detachedConfiguration4 declares a dependency on configuration 'signatures' which is not declared in the module descriptor for group:org.grails, module:grails-datastore-gorm, version:2.0.0.BUILD-SNAPSHOT
17:00:00.530 [ERROR] [org.gradle.BuildExceptionReporter]
When updating a domain class with a 'hasMany' relation, the scaffold code fails with a "Another user has updated this [class] while you were editing" .
You can observe this in the sample code at https://github.com/sarmbruster/neo4jsample , when updating any Attendee record.
Using Riak GORM, this is sent:
POST /mapred HTTP/1.1
Accept: application/json
Content-Type: text/plain;charset=ISO-8859-1
[etc]
And Riak responds with:
HTTP/1.1 415 Unsupported Media Type
The Content-Type should be "application/json"
Hi,
When I install mongodb-gorm plugin I'm getting this issue:
| Configuring classpath
| Error SLF4J: Class path contains multiple SLF4J bindings.
| Error SLF4J: Found binding in
[jar:file:/Users/oliver/.grails/ivy-cache/org.grails/grails-plugin-logging/jars/grails-plugin-logging-2.0.0.M2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
| Error SLF4J: Found binding in
[jar:file:/Users/oliver/.grails/ivy-cache/org.slf4j/slf4j-simple/jars/slf4j-simple-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
| Error SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings
I don't know if this is a Grails issue or plugin issue.
I'm using Grails 2.0.0M2
Thanks!
Currently it is no longer possible to install the simpledb gorm plugin:
==== http://repository.codehaus.org: tried
http://repository.codehaus.org/org/grails/grails-datastore-gorm-simpledb/0.4/grails-datastore-gorm-simpledb-0.4.pom
-- artifact org.grails#grails-datastore-gorm-simpledb;0.4!grails-datastore-gorm-simpledb.jar:
http://repository.codehaus.org/org/grails/grails-datastore-gorm-simpledb/0.4/grails-datastore-gorm-simpledb-0.4.jar
::::::::::::::::::::::::::::::::::::::::::::::
:: UNRESOLVED DEPENDENCIES ::
::::::::::::::::::::::::::::::::::::::::::::::
:: org.grails#grails-datastore-simpledb;0.4: not found
:: org.grails#grails-datastore-gorm-simpledb;0.4: not found
::::::::::::::::::::::::::::::::::::::::::::::
- org.grails:grails-datastore-simpledb:0.4
- org.grails:grails-datastore-gorm-simpledb:0.4
According to the documentation (http://grails.org/plugin/simpledb) it should be in the mavenRepo "http://repository.codehaus.org/" but there is no grails-datastore-gorm-simpledb package in http://repository.codehaus.org/org/grails/
I tried installing the plugin with a fresh 1.3.9 app and a fresh 2.1.1 app - both dont work
The example below extracted from the documentation doesn't work:
class Person { .. static mapping = { collection "mycollection" database "mydb" } }
Grails complains about "collection" not being supported in the static mapping.
Hello,
I ask the question on twitter and it was asked me to open an issue here. It's more a feature request than an actual issue.
Cypher queries allow us to create simple statement to make quite complex operations. The idea is to allow us to query the neo4j DB with a cypher query and then get GORM objects back or simply adding the possibility to bind them thanks to the JSON object gotten from the query result.
Regards,
Leward.
org.grails.datastore.mapping.simple.engine.SimpleMapEntityPersister # generateIdentifier() says in its exception message: "Cannot generator identity for entity"
Should say: "Cannot generate identity for entity"
NB: 'generator' vs 'generate'
Due to JVisualVM CPU Sampling the private method Neo4jSession.addObjectToReverseSide() calls toString() method for GORM Domain Classes with very high frequency when adding lots of data into the graph database.
It appears that toString() method of domain class is called through GString.
Maybe
log.debug "addObjectToReverseSide: property value $propertyValue"
should be surrounded with
if (log.isDebugEnabled()) {
log.debug "addObjectToReverseSide: property value $propertyValue"
}
so that GString is not evaluated for nothing.
Same applies to any case log.debug is used with GStrings.
More convenient method would be to use AST annotations like @slf4j in groovy classes.
See http://www.canoo.com/blog/2010/09/20/log-groovys-new-and-extensible-logging-conveniences/
for more details.
I'm seeing some severe performance issues with the count method on domain classes as the size of the data being counted increases. Replicating the issue is straightforward:
On a fairly beefy mac (2.53 GHz core 2 duo, 8 GB ram), I'm seeing the count method take 15 seconds, on average, for 10,000 records.
Amazon just announced their new NoSQL offering called DynamoDB. So, I thought it would be good to start a sub-project of grails-data-mapping for it. It will probably be very similar to the SimpleDB one. Let me know.
Thanks,
Bobby
The isProxy() method in Neo4jSession consumes a lot of cpu power (about 20% in my case) when adding many-to-many relationships into existing graph database.
change
object.metaClass.methods.any { it.name == 'isProxy'}
to
object.metaClass.getMetaMethod("isProxy", null) != null
or
!object.metaClass.respondsTo("isProxy").isEmpty()
A query of the form
def user = User.get(10) //example
User.createCriteria().list {
friends {
'in' 'id', [user?.id]
}
}
fails with the error:
"No signature of method: org.grails.datastore.gorm.neo4j.Neo4jQuery.matchesCriterionAssociationQuery() is applicable for argument types: (java.util.ArrayList)"
Domain class User
class User {
static hasMany = [friends: User]
}
URI
/graph1/asset/init
Class
groovy.lang.MissingMethodException
Message
No signature of method: org.grails.datastore.gorm.neo4j.Neo4jQuery.hasNonIndexedPropertyCriterion() is applicable for argument types: (java.util.ArrayList, org.grails.datastore.mapping.query.AssociationQuery) values: [[], org.grails.datastore.mapping.query.AssociationQuery@54ebcda1] Possible solutions: hasNonIndexedPropertyCriterion(java.util.Collection, org.grails.datastore.mapping.query.Query$Junction), hasNonIndexedPropertyCriterion(java.util.Collection, org.grails.datastore.mapping.query.Query$PropertyNameCriterion)
// basic query w/ an association..
def aclObjectIdentities = AclObjectIdentity.withCriteria {
for (ObjectIdentity objectIdentity in objectIdentities) {
or {
eq('objectId', objectIdentity.identifier)
aclClass {
eq('className', objectIdentity.type)
}
}
}
order('objectId', 'asc')
}
Consider the first query:
def books = Book.withCriteria {
eq("category", "fiction")
}
How can I use the result of this query in the next query to get all the authors who wrote these books?
I tried:
def authors = Author.withCriteria {
'in'("books", books)
}
but this is not working. What can I do to fix it?
When using the simpledb, but no domains use HiLo in IdentityGeneration, the plugin will still create the HiLo domain.
I have a domain class:
class Book {
String id
Date dateCreated
Date lastUpdated
String title
boolean acceptPolicy // defines if the user accepts the terms and privacy poicy
String uploadImageId
static transients = [ "acceptPolicy" ]
static constraints = {
acceptPolicy( validator: { val, obj -> val == true} )
}
}
I choose "acceptPolicy" as a field which should not be stored in the database. When I create a book object everything works find. The problem occurs when I update the book instance. Every time I try to save I get a validation error for the "acceptPolicy". This should not be the case because "acceptPolicy" is not stored in the database. I also tried to set the
acceptPolicy = true
in a hidden input field but still this problem occurs. How can I fix it?
When doing batch inserts despite calling X.withSession { session -> session.clear() } on a regular basis, there are still memory leaks because session.clear() does not clear the org.grails.datastore.mapping.core.AbstractSession objectToKey map.
Perhaps AbstractSession or MongoSession should do the same as Neo4jSession, which is to override clear() to also clear the objectToKey map.
I didn't debug this down into the framework or the plugin.. only it wasn't working a quick change from findWhere to createCriteria solved the issue.
Reproduction:
grails create-app testspringcore
grails install-plugin spring-security-core
grails s2-quickstart
Code in the gormUserDetailsService using findWhere was not finding the user.
Workaround --
resource.groovy:
import workaround.MyUserDetailsService;
beans = {
userDetailsService(MyUserDetailsService) {
grailsApplication = ref('grailsApplication')
}
}
Diff GormUserDetailsService
def user = User.findWhere((conf.userLookup.usernamePropertyName): username)
Replaced it w/ a criteria
def user = User.createCriteria().get { eq(conf.userLookup.usernamePropertyName, username) }
Just wondering, why does the mongo GORM driver require _embeddedClassName, can not be determined by looking at the Domain class using reflection? Looking at the code it seems to be baked into the code, and there seems to be no way of disabling this. Could this be a possible addition, as I'm working with a dataset that cannot be altered.
MongoDatastore.java
line 200:
for (PersistentEntity entity : mappingContext.getPersistentEntities()) {
// Only create Mongo templates for entities that are mapped with Mongo
if (!entity.isExternal()) {
createMongoTemplate(entity, mongo);
}
}
entity.isExternal() is false for all entities I've got even if they are not mapped with mongo.
The problem occured when I created domain class with property database, with constraint field database(nullable:true). When you do so, application won't start because of:
Caused by IllegalArgumentException: Database name must only contain letters, numbers, underscores and dashes!
It turns out that somehow MongoDatastore.java:220
if (mongoCollection.getDatabase() != null) {
databaseName = mongoCollection.getDatabase();
}
databaseName becomes "{nullable=true}".
The constraint propagates to the mongoCollection properties. This behaviour seems to be legitimate but the error wouldn't occur if mongoTemplates were made only for mongo mapped domain classes.
This in grails-app/conf/BootStrap.groovy makes neo4j rock in Groovy/Grails:
def init = { servletContext ->
def getOrSet = { name, value = null ->
if(value) {
delegate.setProperty(name,value instanceof Date ? value.time : value)
} else {
def val = delegate.getProperty(name, null)
if(val instanceof Long && name.endsWith('Date'))
return new Date(val)
return val
}
}
NodeProxy.metaClass.propertyMissing = getOrSet
RelationshipProxy.metaClass.propertyMissing = getOrSet
RestNode.metaClass.propertyMissing = getOrSet
Relationship.metaClass.propertyMissing = getOrSet
JSON.registerObjectMarshaller(NodeProxy) { n ->
def m = [:]
m.id = n.id
n.propertyKeys.each { k ->
m[(k)] = n."$k"
}
m.relationships = n.relationships.collect{it}
m
}
JSON.registerObjectMarshaller(RelationshipProxy) { r ->
def m = [:]
m.id = r.id
m.type = r.type.name()
m.startNode = r.startNode.id
m.endNode = r.endNode.id
r.propertyKeys.each { k ->
m[(k)] = r."$k"
}
m
}
}
Maybe it would be worth to add something like this into the neo4j Grails plugin. ;)
I have a domain class with 2 properties on the many-side of a one-to-many relationship, but the 'mappedBy' specification is not being honored when creating the relationships.
Better explained with an example-
class User {
static hasMany = [profiles: Profile, tags: Profile]
static mappedBy = [profiles: 'ownedBy', tags: 'taggedBy']
}
class Profile {
User ownedBy
User taggedBy
}
def a = new User().save()
def b = new User().save()
def p = new Profile(onwedBy: a, taggedBy: b).save()
If you see the results in the data browser, there is two 'tags' relationships into profile and no 'profiles' relationships, whereas I would expect only one 'tags' and one 'profiles' relationship. The other relationships are correctly saved
Thanks.
Hello,
I'm getting a strange behavior when deleting domain objects in grails using the neo4j plugin: I can delete them if I only have the instance of the object that I want to delete; if I have an instance of another object which has a relationship with the object I want to delete, even if I don't use it, I get an error:
| Error 2012-04-23 08:50:21,320 [http-bio-8080-exec-4] ERROR errors.GrailsExceptionResolver - IllegalStateException occurred when processing request: [DELETE] /Prismio/users/pat - parameters:
dummyToken: pat
Second node[6] is deleted and cannot be used to create a relationship. Stacktrace follows:
Message: Second node[6] is deleted and cannot be used to create a relationship
Line | Method
->> 1365 | relationshipCreate in org.neo4j.kernel.impl.nioneo.xa.WriteTransaction
| 161 | relationshipCreate in org.neo4j.kernel.impl.persistence.PersistenceManager
| 321 | createRelationship . in org.neo4j.kernel.impl.core.NodeManager
| 499 | createRelationshipTo in org.neo4j.kernel.impl.core.NodeImpl
| 198 | createRelationshipTo in org.neo4j.kernel.impl.core.NodeProxy
| 331 | doCall in org.grails.datastore.gorm.neo4j.Neo4jSession$_writeToManyProperty_closure5
| 325 | writeToManyProperty in org.grails.datastore.gorm.neo4j.Neo4jSession
| 246 | flush in ''
| 226 | doCall . . . . . . . in org.grails.datastore.gorm.GormInstanceApi$_delete_closure8
| 301 | execute in org.grails.datastore.mapping.core.DatastoreUtils
| 34 | execute . . . . . . in org.grails.datastore.gorm.AbstractDatastoreApi
| 223 | delete in org.grails.datastore.gorm.GormInstanceApi
| 251 | call . . . . . . . . in org.grails.datastore.gorm.InstanceMethodInvokingClosure
| 32 | deleteUser in com.prismio.api.UserService
| 31 | deleteUser . . . . . in com.prismio.api.UserController
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 679 | run in java.lang.Thread
I'm on Grails 2.0.1 on Linux 64 bit, with OpenJdk 1.6.0_24 and the Neo4j plugin 1.0.0.M2
class User {
String userId
String password
Date dateCreated
Date lastUpdated
String email
boolean active = false
boolean requireAuthorizationToFollow = false
static hasMany = [follows : User]
}
This code works:
def deleteUser(User user){
user.delete(flush: true)
}
This code doesn't work:
def deleteUser(User user){
def user2 = User.findByUserId("alex")
user.delete(flush: true)
}
I tried this because I was getting a strange behavior on another domain object while the code above was working, until I added the instance user2.
I also did some more testing and got these results:
Regards
Alessandro
When using Neo4j data-mapping, Bootstrap doesn't have any transactional context. Calling a service that tries to persist domain, results in NotInTransaction exception.
A workaround is to wrap the call as,
def result = new TransactionTemplate(neo4jTransactionManager).execute({ status ->
....
....
} as TransactionCallback)
Created a test app to show the performance:
https://github.com/wdroste/Performance-Test-Neo4j
To execute the test:
http://localhost:8080/perf/governor/performance
w/ no attributes it takes about 74-400ms to create 10 objects w/ one relationship
w/ 1 attribute it takes the same operation 5800ms to create 10 objects w/ one relationship
Need more/better information on the queries being sent to the Neo4J instance through logging statements. This is often useful for debugging and tuning the app.
using Springsecurity Core and putting mongod in notablescan mode, i tried setting an index everywhere.
static mapping = {
id composite: ['role', 'user'], name:"id"
user index:true
}
creates an index on the user dbref or something, however it should be created the following way:
db.userRole.ensureIndex({ "user.$id" : 1 },{ "name" : "user.$id" });
Workaround (this should be added for the documentation for the time being)
compoundIndex 'user.$id':1
Note: Probably this needs to be fixed 2x, once for reference: false and once for the DBRef mode.
Minor ticket
1.0.1
If you don't setup the grails.neo4j bean the user gets this for all grails commands..
| Error Error running generate-all (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '{}' with class 'java.lang.String' to class 'java.lang.Class' due to: java.lang.ClassNotFoundException: {}
at org.grails.datastore.gorm.neo4j.plugin.support.Neo4jSpringConfigurer$_getSpringCustomizer_closure1.doCall(Neo4jSpringConfigurer.groovy:77)
at org.grails.datastore.gorm.plugin.support.SpringConfigurer$_configureSpring_closure1.doCall(SpringConfigurer.groovy:123)
at grails.spring.BeanBuilder.invokeBeanDefiningClosure(BeanBuilder.java:736)
at grails.spring.BeanBuilder.beans(BeanBuilder.java:569)
at grails.spring.BeanBuilder.invokeMethod(BeanBuilder.java:511)
at _GrailsBootstrap_groovy$_run_closure2_closure17.doCall(_GrailsBootstrap_groovy:105)
at _GrailsBootstrap_groovy$_run_closure2.doCall(_GrailsBootstrap_groovy:97)
at _GrailsBootstrap_groovy$_run_closure6.doCall(_GrailsBootstrap_groovy:131)
at _GrailsGenerate_groovy$_run_closure1.doCall(_GrailsGenerate_groovy:43)
at GenerateAll$_run_closure1.doCall(GenerateAll:42)
Consider the following simple neo4j mapped domain classes:
class Organization {
String name
static hasMany = [people: Person]
static mapWith = "neo4j"
static mapping = {
people(lazy: true)
}
}
class Person {
String firstName
String lastName
static mapWith = "neo4j"
static constraints = {
firstName(nullable: false, blank: false, maxSize: 500)
lastName(nullable: false, blank: false, maxSize: 500)
}
static belongsTo = [organization: Organization]
}
My testing so far seems to indicate that the lazy: true mapping in the Organization domain class is not respected since the time it take to load an organization record greatly slows own as the number of people associated with is increased.
Is the lazy collection loading in neo4j gorm intended to be supported? I apologize if I missed something in the existing documentation already explaining this.
Thanks,
Phil
There is no any documentation that will help to avoid deep digging into the code to start even Hello World.
I'm using the grails-mongo with custom complex types. From the custom property example in the docs:
class Birthday implements Comparable, Serializable {
Date date
Birthday(Date date) {
this.date = date
}
@Override
int compareTo(Object t) {
date.compareTo(t.date)
}
}
class RegularPerson {
static mapWith = "mongo"
String name
Birthday birthday
}
class BirthdayType extends AbstractMappingAwareCustomTypeMarshaller<Birthday, DBObject, DBObject> {
BirthdayType() {
super(Birthday)
}
@Override
protected Object writeInternal(PersistentProperty property, String key, Birthday value, DBObject nativeTarget) {
final converted = value.date.time
nativeTarget.put(key, converted)
return converted
}
@Override
protected Birthday readInternal(PersistentProperty property, String key, DBObject nativeSource) {
final num = nativeSource.get(key)
if(num instanceof Long) {
return new Birthday(new Date(num))
}
return null
}
}
However, in my use case, I'm looking to persist a list of custom types, e.g.:
class BornAgainPerson {
static mapWith = "mongo"
String name
List<Birthday> birthdays
}
When I attempt to save a BornAgainPerson
:
BornAgainPerson jane = new BornAgainPerson(
name: 'Jane Smith',
birthdays: [
new Birthday(new Date())
]
)
jane.save(flush: true)
println "jane errors: ${jane.errors.allErrors}"
I'm greeted with the following error:
| Error 2012-07-30 21:56:30,835 [pool-7-thread-1] ERROR context.GrailsContextLoader - Error executing bootstraps: can't serialize class Birthday
Message: can't serialize class Birthday
Line | Method
->> 234 | _putObjectField in org.bson.BasicBSONEncoder
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 259 | putIterable in ''
| 198 | _putObjectField . . . . . . . . in ''
| 140 | putObject in ''
| 86 | putObject . . . . . . . . . . . in ''
| 27 | writeObject in com.mongodb.DefaultDBEncoder
| 142 | putObject . . . . . . . . . . . in com.mongodb.OutMessage
| 252 | insert in com.mongodb.DBApiLayer$MyCollection
| 211 | insert . . . . . . . . . . . . . in ''
| 57 | insert in com.mongodb.DBCollection
| 153 | doInDB . . . . . . . . . . . . . in org.grails.datastore.mapping.mongo.MongoSession$1
| 129 | flushPendingInserts in org.grails.datastore.mapping.mongo.MongoSession
| 237 | flush . . . . . . . . . . . . . in org.grails.datastore.mapping.core.AbstractSession
| 113 | flush in org.grails.datastore.mapping.mongo.MongoSession
| 168 | doSave . . . . . . . . . . . . . in org.grails.datastore.gorm.GormInstanceApi
| 143 | doCall in org.grails.datastore.gorm.GormInstanceApi$_save_closure4
| 301 | execute . . . . . . . . . . . . in org.grails.datastore.mapping.core.DatastoreUtils
| 34 | execute in org.grails.datastore.gorm.AbstractDatastoreApi
| 142 | save . . . . . . . . . . . . . . in org.grails.datastore.gorm.GormInstanceApi
| 258 | call in org.grails.datastore.gorm.InstanceMethodInvokingClosure
| 10 | doCall . . . . . . . . . . . . . in BootStrap$_closure1
| 301 | evaluateEnvironmentSpecificBlock in grails.util.Environment
| 294 | executeForEnvironment . . . . . in ''
| 270 | executeForCurrentEnvironment in ''
| 303 | innerRun . . . . . . . . . . . . in java.util.concurrent.FutureTask$Sync
| 138 | run in java.util.concurrent.FutureTask
| 886 | runTask . . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
| 908 | run in ''
^ 680 | run . . . . . . . . . . . . . . in java.lang.Thread
Looking into this, it appears that the NativeEntityPersister
is detecting the field as either a Simple
or Basic
type, presumably because it's a List
:
if ((prop instanceof Simple) || (prop instanceof Basic)) {
Object propValue = entityAccess.getProperty(prop.getName());
handleIndexing(isUpdate, e, toIndex, toUnindex, prop, key, indexed, propValue);
setEntryValue(e, key, propValue);
}
else if ((prop instanceof Custom)) {
CustomTypeMarshaller customTypeMarshaller = ((Custom) prop).getCustomTypeMarshaller();
if (customTypeMarshaller.supports(getSession().getDatastore())) {
Object propValue = entityAccess.getProperty(prop.getName());
Object customValue = customTypeMarshaller.write(prop, propValue, e);
handleIndexing(isUpdate, e, toIndex, toUnindex, prop, key, indexed, customValue);
}
}
Thus, at persistence time, the List<Birthday>
is being punted out in BasicBSONEncoder._putObjectField
because it doesn't know how to handle that type:
protected void _putObjectField( String name , Object val ){
if ( name.equals( "_transientFields" ) )
return;
if ( DEBUG ) System.out.println( "\t put thing : " + name );
if ( name.equals( "$where") && val instanceof String ){
_put( CODE , name );
_putValueString( val.toString() );
return;
}
val = BSON.applyEncodingHooks( val );
if ( val == null )
putNull(name);
else if ( val instanceof Date )
putDate( name , (Date)val );
else if ( val instanceof Number )
putNumber(name, (Number)val );
else if ( val instanceof String )
putString(name, val.toString() );
else if ( val instanceof ObjectId )
putObjectId(name, (ObjectId)val );
else if ( val instanceof BSONObject )
putObject(name, (BSONObject)val );
else if ( val instanceof Boolean )
putBoolean(name, (Boolean)val );
else if ( val instanceof Pattern )
putPattern(name, (Pattern)val );
else if ( val instanceof Map )
putMap( name , (Map)val );
else if ( val instanceof Iterable)
putIterable( name , (Iterable)val );
else if ( val instanceof byte[] )
putBinary( name , (byte[])val );
else if ( val instanceof Binary )
putBinary( name , (Binary)val );
else if ( val instanceof UUID )
putUUID( name , (UUID)val );
else if ( val.getClass().isArray() )
putArray( name , val );
else if (val instanceof Symbol) {
putSymbol(name, (Symbol) val);
}
else if (val instanceof BSONTimestamp) {
putTimestamp( name , (BSONTimestamp)val );
}
else if (val instanceof CodeWScope) {
putCodeWScope( name , (CodeWScope)val );
}
else if (val instanceof Code) {
putCode( name , (Code)val );
}
else if (val instanceof DBRefBase) {
BSONObject temp = new BasicBSONObject();
temp.put("$ref", ((DBRefBase)val).getRef());
temp.put("$id", ((DBRefBase)val).getId());
putObject( name, temp );
}
else if ( val instanceof MinKey )
putMinKey( name );
else if ( val instanceof MaxKey )
putMaxKey( name );
else if ( putSpecial( name , val ) ){
// no-op
}
else {
throw new IllegalArgumentException( "can't serialize " + val.getClass() );
}
}
As an alternative approach, I tried defining a BirthdayList
class specifically:
class BirthdayList extends ArrayList<Birthday> { }
and a custom type marshaller specifically for this list type:
class BirthdayListType extends AbstractMappingAwareCustomTypeMarshaller<BirthdayList, DBObject, DBObject> {
BirthdayListType() {
super(BirthdayList)
}
@Override
protected Object writeInternal(PersistentProperty property, String key, BirthdayList value, DBObject nativeTarget) {
BasicDBList list = new BasicDBList();
for(Birthday birthday : value) {
list.add(birthday.date.time)
}
nativeTarget.put(key, list)
return list
}
@Override
protected BirthdayList readInternal(PersistentProperty property, String key, DBObject nativeSource) {
final sourceList = nativeSource.get(key)
if(num instanceof List<Long>) {
BirthdayList list = new BirthdayList()
for(Long num : sourceList) {
list.add(new Birthday(num))
}
return list
}
return null
}
}
Unfortunately, this had no effect even after registering both marshallers in resources.groovy
:
beans = {
birthdayType(BirthdayType)
birthdayListType(BirthdayListType)
}
Presumably, the evaluation of a List
as a Simple
or Basic
type supersedes the custom marshallers.
I haven't yet located the code that determines the property types, but hope to do so soon.
In the meantime, I wanted to throw this out there as an issue. Ideally, Grails should detect collections of custom types and call the proper custom marshaller on each of its elements.
I've also created a sample project to reproduce the issue, both using a simple list and a custom list type.
The redis-gorm plugin was modified to rely on the redis plugin for much of it's work. They still use separate datasources though, and the redis-gorm plugin needs to be refactored to have it's plugin config renamed so that it matches the plugin name.
Currently, with the released redis-gorm plugin code, if you make an application and install the redis-gorm plugin. Then if you create a test that exercises redis:
package com.example
import grails.test.*
class RedisIntegrationTests extends GroovyTestCase {
def redisService
void testSomething() {
redisService.foo = "bar"
assert "bar" == redisService.foo
}
}
You'll see that it blows up if you try to use a config like this:
grails.redis.host="locahost"
grails.redis.port=6379
grails.redis.pooled=true
grails.redis.resources=15
grails.redis.timeout=5000
You'll get a stacktrace like this:
Error executing script TestApp: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisTransactionManager': Cannot resolve reference to bean 'redisDatastore' while setting bean property 'datastore'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisDatastore': Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'groovy.util.ConfigObject' to required type 'java.util.Map' for property 'config'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [groovy.util.ConfigObject] to required type [java.lang.String] for property 'config[poolConfig]': no matching editors or conversion strategy found
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisTransactionManager': Cannot resolve reference to bean 'redisDatastore' while setting bean property 'datastore'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisDatastore': Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'groovy.util.ConfigObject' to required type 'java.util.Map' for property 'config'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [groovy.util.ConfigObject] to required type [java.lang.String] for property 'config[poolConfig]': no matching editors or conversion strategy found
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:391)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:590)
at gant.Gant.executeTargets(Gant.groovy:589)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisTransactionManager': Cannot resolve reference to bean 'redisDatastore' while setting bean property 'datastore'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisDatastore': Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'groovy.util.ConfigObject' to required type 'java.util.Map' for property 'config'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [groovy.util.ConfigObject] to required type [java.lang.String] for property 'config[poolConfig]': no matching editors or conversion strategy found
at _GrailsBootstrap_groovy$_run_closure2_closure14.doCall(_GrailsBootstrap_groovy:102)
at _GrailsBootstrap_groovy$_run_closure2_closure14.doCall(_GrailsBootstrap_groovy)
at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:280)
at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
at _GrailsBootstrap_groovy$_run_closure2.doCall(_GrailsBootstrap_groovy:94)
at _GrailsBootstrap_groovy$_run_closure6.doCall(_GrailsBootstrap_groovy:152)
at _GrailsTest_groovy$_run_closure9.doCall(_GrailsTest_groovy:314)
at _GrailsTest_groovy$_run_closure9.doCall(_GrailsTest_groovy)
at _GrailsTest_groovy$_run_closure1_closure21.doCall(_GrailsTest_groovy:184)
at _GrailsTest_groovy$_run_closure1.doCall(_GrailsTest_groovy:174)
at TestApp$_run_closure1.doCall(TestApp.groovy:82)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
... 10 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisTransactionManager': Cannot resolve reference to bean 'redisDatastore' while setting bean property 'datastore'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisDatastore': Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'groovy.util.ConfigObject' to required type 'java.util.Map' for property 'config'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [groovy.util.ConfigObject] to required type [java.lang.String] for property 'config[poolConfig]': no matching editors or conversion strategy found
... 22 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisDatastore': Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'groovy.util.ConfigObject' to required type 'java.util.Map' for property 'config'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [groovy.util.ConfigObject] to required type [java.lang.String] for property 'config[poolConfig]': no matching editors or conversion strategy found
... 22 more
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'groovy.util.ConfigObject' to required type 'java.util.Map' for property 'config'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [groovy.util.ConfigObject] to required type [java.lang.String] for property 'config[poolConfig]': no matching editors or conversion strategy found
... 22 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type [groovy.util.ConfigObject] to required type [java.lang.String] for property 'config[poolConfig]': no matching editors or conversion strategy found
... 22 more
--- Nested Exception ---
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisTransactionManager': Cannot resolve reference to bean 'redisDatastore' while setting bean property 'datastore'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisDatastore': Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'groovy.util.ConfigObject' to required type 'java.util.Map' for property 'config'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [groovy.util.ConfigObject] to required type [java.lang.String] for property 'config[poolConfig]': no matching editors or conversion strategy found
at _GrailsBootstrap_groovy$_run_closure2_closure14.doCall(_GrailsBootstrap_groovy:102)
at _GrailsBootstrap_groovy$_run_closure2_closure14.doCall(_GrailsBootstrap_groovy)
at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:280)
at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
at _GrailsBootstrap_groovy$_run_closure2.doCall(_GrailsBootstrap_groovy:94)
at _GrailsBootstrap_groovy$_run_closure6.doCall(_GrailsBootstrap_groovy:152)
at _GrailsTest_groovy$_run_closure9.doCall(_GrailsTest_groovy:314)
at _GrailsTest_groovy$_run_closure9.doCall(_GrailsTest_groovy)
at _GrailsTest_groovy$_run_closure1_closure21.doCall(_GrailsTest_groovy:184)
at _GrailsTest_groovy$_run_closure1.doCall(_GrailsTest_groovy:174)
at TestApp$_run_closure1.doCall(TestApp.groovy:82)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:590)
at gant.Gant.executeTargets(Gant.groovy:589)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisTransactionManager': Cannot resolve reference to bean 'redisDatastore' while setting bean property 'datastore'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisDatastore': Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'groovy.util.ConfigObject' to required type 'java.util.Map' for property 'config'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [groovy.util.ConfigObject] to required type [java.lang.String] for property 'config[poolConfig]': no matching editors or conversion strategy found
... 22 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisDatastore': Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'groovy.util.ConfigObject' to required type 'java.util.Map' for property 'config'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [groovy.util.ConfigObject] to required type [java.lang.String] for property 'config[poolConfig]': no matching editors or conversion strategy found
... 22 more
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'groovy.util.ConfigObject' to required type 'java.util.Map' for property 'config'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [groovy.util.ConfigObject] to required type [java.lang.String] for property 'config[poolConfig]': no matching editors or conversion strategy found
... 22 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type [groovy.util.ConfigObject] to required type [java.lang.String] for property 'config[poolConfig]': no matching editors or conversion strategy found
... 22 more
Error executing script TestApp: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisTransactionManager': Cannot resolve reference to bean 'redisDatastore' while setting bean property 'datastore'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisDatastore': Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'groovy.util.ConfigObject' to required type 'java.util.Map' for property 'config'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [groovy.util.ConfigObject] to required type [java.lang.String] for property 'config[poolConfig]': no matching editors or conversion strategy found
I think that there might be a bigger bug with the way the redis-gorm plugin is pulling in
At the very least, the RedisSpringConfigurer should probably be refactored to it's own configuration space with something like this:
diff --git a/grails-datastore-gorm-redis/src/main/groovy/org/grails/datastore/gorm/redi
index 9d79edd..64160f6 100644
--- a/grails-datastore-gorm-redis/src/main/groovy/org/grails/datastore/gorm/redis/plugi
+++ b/grails-datastore-gorm-redis/src/main/groovy/org/grails/datastore/gorm/redis/plugi
@@ -29,7 +29,7 @@ class RedisSpringConfigurer extends SpringConfigurer{
@Override
Closure getSpringCustomizer() {
return {
- def redisConfig = application.config?.grails?.redis
+ def redisConfig = application.config?.grails?.redis-gorm
redisDatastoreMappingContext(RedisMappingContextFactoryBean) {
grailsApplication = ref('grailsApplication')
(thanks to Christian Oestreich for the bug report and details)
Longer term, the redis-gorm plugin should be refactored to rely on the same datasource as the redis plugin has.
grails-data-core has an explicit compile dependency on
"com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.2_jdk5"
where this should only be required when working with JDK 1.5 and version 1.3.1/2 should be used for JDK 1.5+.
Currently its causing a conflict with another library that uses version concurrentlinkedhashmap-lru:1.3.1, which is the correct version to use for JDK 1.6.
Can some one update the dependency and add a classifier?
when deploying neo4jsample app to heroku it does not startup, heroku logs
contains
org.codehaus.jackson.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')| at [Source: java.io.StringReader@560c7816; line: 1, column: 2]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.