Giter Site home page Giter Site logo

Comments (14)

jasperblues avatar jasperblues commented on June 28, 2024

Glad it was helpful. You're right, its necessary to run the test first, which creates a user. Otherwise doc is missing. I will add.

CREATE (u:User {applicationToken:"ba2ab43b-01e6-4425-8089-f0ade3db28c3", email:"[email protected]", firstName:"YourFirstName", joined:"2018-10-13T01:28:22.771Z", lastActive:"2018-10-13T01:28:22.771Z", lastName:"YourLastName", password:"password", uuid:"b4342c76-f693-4205-8ffd-22d56b92cbbb" })

Can you please try running the tests first?

The sample should be updated to use new persistence constructor support.

from movies-kotlin-spring-data-neo4j.

rlhLegoSoft avatar rlhLegoSoft commented on June 28, 2024

Thanks for your request!!.. With your answer the /authorization test works fine. I will try more tests and migrate your example to maven and a different ne04j database and use LDAP instead of neo4j.
But again, your example was very helpful to integrate spring data, spring security and neo4j using Kotlin.
I'm more a scala fan (the neo4j scala wrapper is very nice https://github.com/FaKod/neo4j-scala). But with your excellent example, now I have doubts which path to follow.

from movies-kotlin-spring-data-neo4j.

rlhLegoSoft avatar rlhLegoSoft commented on June 28, 2024

I tried your solution and it works 'outside' the test unit (i.e., as REST calls). But when I tried to use your @test units several errors occur:

1.- The @service, @configuration, etc classes that Spring boot initializes, asked me 'not to be final' (so I declared 'open'). I think this is wrong, because how did they run to you. Any idea? (again I'm Spring boot beginer, sorry).

2.- Send and exception in the TestDataLoader class when tries to read User entry:

The stack trace is:
....
Caused by: java.lang.NoSuchMethodException: movies.spring.data.neo4j.domain.model.persistent.entities.User.()
at java.lang.Class.getConstructor0(Class.java:3074)
at java.lang.Class.getDeclaredConstructor(Class.java:2170)
at org.neo4j.ogm.metadata.reflect.EntityFactory.instantiate(EntityFactory.java:130)
... 96 common frames omitted
....

I believed is because a previous warning are shown:
...
2018-10-15 13:41:26.207 WARN 2359 --- [ main] o.s.d.n.mapping.Neo4jPersistentProperty : No identity field found for class of type: movies.spring.data.neo4j.domain.model.persistent.entities.User when creating persistent property for : private java.lang.String movies.spring.data.neo4j.domain.model.persistent.entities.User.uuid
2018-10-15 13:41:26.208 WARN 2359 --- [ main] o.s.d.n.mapping.Neo4jPersistentProperty : No identity field found for class of type: movies.spring.data.neo4j.domain.model.persistent.entities.User when creating persistent property for : private java.lang.String movies.spring.data.neo4j.domain.model.persistent.entities.User.applicationToken
2018-10-15 13:41:26.208 WARN 2359 --- [ main] o.s.d.n.mapping.Neo4jPersistentProperty : No identity field found for class of type: movies.spring.data.neo4j.domain.model.persistent.entities.User when creating persistent property for : private java.lang.String movies.spring.data.neo4j.domain.model.persistent.entities.User.firstName
2018-10-15 13:41:26.209 WARN 2359 --- [ main] o.s.d.n.mapping.Neo4jPersistentProperty : No identity field found for class of type: movies.spring.data.neo4j.domain.model.persistent.entities.User when creating persistent property for : private java.lang.String movies.spring.data.neo4j.domain.model.persistent.entities.User.lastName
2018-10-15 13:41:26.210 WARN 2359 --- [ main] o.s.d.n.mapping.Neo4jPersistentProperty : No identity field found for class of type: movies.spring.data.neo4j.domain.model.persistent.entities.User when creating persistent property for : private java.lang.String movies.spring.data.neo4j.domain.model.persistent.entities.User.email
2018-10-15 13:41:26.210 WARN 2359 --- [ main] o.s.d.n.mapping.Neo4jPersistentProperty : No identity field found for class of type: movies.spring.data.neo4j.domain.model.persistent.entities.User when creating persistent property for : private java.lang.String movies.spring.data.neo4j.domain.model.persistent.entities.User.password
....

Any idea what I am doing wrong?

from movies-kotlin-spring-data-neo4j.

jasperblues avatar jasperblues commented on June 28, 2024

Kotlin, by default, classes are closed, however with Spring - the way it implements @Transacational and some related features - using cglib and runtime generated subclasses, it requires the classes to be open.

Rather than having to manage this manually though, it can be transparent using the all-open and kotlin-spring plugins.

Probably you started migrating to Maven, as you mentioned, and didn't add those yet?

from movies-kotlin-spring-data-neo4j.

rlhLegoSoft avatar rlhLegoSoft commented on June 28, 2024

I done that all Koltlin classes by default are final. My question is why it worked fine outside Eclipse calling the /authentication as a REST service?
No I could migrate to maven yet since I'm still having the problem because the mapping User entity problem and cannot persist User. I will work today to try to solve this problem.
Thanks.

from movies-kotlin-spring-data-neo4j.

jasperblues avatar jasperblues commented on June 28, 2024

I'm not sure - the tests are working from here. Good luck - feel free to reach out if you have any more questions.

from movies-kotlin-spring-data-neo4j.

jasperblues avatar jasperblues commented on June 28, 2024

I will close this issue, and you can open another if you wish :)

from movies-kotlin-spring-data-neo4j.

rlhLegoSoft avatar rlhLegoSoft commented on June 28, 2024

First problem solved !! : In Eclipse you need the preferences for Kotlin compiler need to check the spring(inherited) if not the all-open does not work.
Keep working in the user mapping error (inside Eclipse it send an error): I will let you know

from movies-kotlin-spring-data-neo4j.

jasperblues avatar jasperblues commented on June 28, 2024

๐ŸŽ‰ ๐Ÿ‘ :)

from movies-kotlin-spring-data-neo4j.

rlhLegoSoft avatar rlhLegoSoft commented on June 28, 2024

I found the mapping error (I don't know why it didยดnt happened to you): The problem was when a Neo4j jury was executed (i.e., MATCH (n:User) WHERE n.email = { email_0 } WITH n RETURN n,[ [ (n)-[r_l1:LIKES]->(m1:Movie) | [ r_l1, m1 ] ] ], ID(n) with params {email_0=[email protected]} Spring data tried to instantiated User 'with' no parameters. And this constructors did not exists. So I need to add the following code in User.kt file:
constructor (): this(firstName = "", lastName ="", email ="", password ="") {
}
Now Spring Data can execute new User(); /* java code */ using reflection with no problem.

My question is : Why it didn't happened to you?

from movies-kotlin-spring-data-neo4j.

jasperblues avatar jasperblues commented on June 28, 2024

When the example was created Spring Data Neo4j didn't support persistence constructors, but now it does.

If you are able to update the sample to show usage of persistence constructors feature (make the entity immutable by changing props to val) that would be awesome.

^-- i think this would be the reason

from movies-kotlin-spring-data-neo4j.

rlhLegoSoft avatar rlhLegoSoft commented on June 28, 2024

But making the entities inmutable (i.e., changing the props to val) I believe it will not work:

  • First your test cases make mutable operations (put) for User Movie, etc.
  • Second I believe that Spring Data does not use the constructor with the props, but an empty constructor and later on it sets the props using the setter methods generated by Kotlin compiler.

Don't you think?

from movies-kotlin-spring-data-neo4j.

jasperblues avatar jasperblues commented on June 28, 2024

There is a new feature called persistence constructors, means you can have immutable entities, if you want, as a design decision.

Kotlin has a nice way to create copies (new instances) with mutations.

You don't have to do this, but its now an option.

from movies-kotlin-spring-data-neo4j.

rlhLegoSoft avatar rlhLegoSoft commented on June 28, 2024

I don't know about 'persistence constructors' and how Kotlien make inmutable copies with mutations.

Let me check for these features. I want to check since your example is guide us to create a production application that we plan to develop (an Identity Manager system for a Bank using Neo4j).

So any help is welcome

from movies-kotlin-spring-data-neo4j.

Related Issues (5)

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.