Spring Data Neo4j (SDN) 4.0 runtime polymorphism - spring

Spring Data Neo4j (SDN) 4.0 did away with #RelationshipType and #Labels, among other tools that could be used to implement dynamic typing or runtime polymorphism. In SDN 4.0 all polymorphic possibilities (labels and relationship types) must be modeled explicitly, statically, in Java prior to build time. Given those limitations, I am unable to migrate my SDN 3.x code, which took advantage of those features, forward.
I would appreciate any insight, work arounds, alternative tools, etc. anyone has to offer. The only alternative right now that I see is to unplug SDN and write directly to Neo4j.
Thanks

We're very aware that the lack of runtime polymorphism is currently frustrating some SDN 3 users who want to migrate to SDN 4. And while there may be workarounds in many cases, we also accept that having to refactor application code is not ideal.
We do want to address this, however to enable runtime polymorphism will require both architectural and implementation changes, so its not something we can expect to accomplish in just a few days. Unfortunately, right now we can't commit to when we will be in a position to start that work, because the product road map is still being discussed with the development team and the product owner, Neo Technology.
If you can stay with SDN 3 that might be the best option right now until this feature is available in SDN 4.

Related

Why have coding over configuration at all?

When we talk about spring (which ever module say jdbc), one of the reasons we use it is because it enables dependency injection and controls lifecycle of beans/classes. In programming, one of the most important fundamental is to code for interfaces rather than implementations, so today if I am using sql server driver v1, I can change it to v2 tomorrow if my code is written in such a way that it cares about Driver interface and not the implementations, then in what case would I ever need coding over configuration ?
The wording of your question seems a bit strange to me. Perhaps you are asking if there are any drawbacks to using Spring-like dependency injection. I can think of a few drawbacks, but whether these drawbacks outweigh the potential benefits of Spring is a matter of opinion.
Unfortunately, a Spring XML file is much more verbose than code to achieve similar (but hard-coded) initialisation of objects.
A programmer has to look not just at code but also at a Spring XML file to figure out what is going on. This, arguably, is a form of the Yo-yo problem.
One significant benefit of Spring is that it can be used to instantiate and configure any Java class (assuming the classes provide getters and setters). In particular, Java classes do not need to be polluted with the need to inherit from framework infrastructure classes. If you don't mind polluting classes with the need to inherit from framework infrastructure, then it is possible to have much more concise configuration files for instantiating and configuring objects. A case study illustrating this idea can be found in Chapters 9, 10 and 11 of the Config4* Practical Usage Guide. I am not proposing that the approach used in that case study be used for all applications, but I think it is a good approach to use when there is a complex, standardised API (such as for JMS) that is implemented by multiple products. In the case study, the approach results in a significantly easier-to-use API and eliminates some potential bugs from applications. Spring doesn't offer such benefits.
Section 9.4.2 of the Config4* Practical Usage Guide outlines a 9-step initialisation process for typical JMS applications. The framework library discussed in the case study ensures that those 9 steps are carried out in the correct order. It has been years since I looked at Spring so I might be wrong, but I don't think Spring has the flexibility to (easily or perhaps at all) enforce such a complex 9-step initialisation mechanism.

Which graphql-spring-boot-starter should I choose?

I'm thinking about adding GraphQL functionalities to my Spring Boot application.
I found there are two artifacts for that.
One is com.graphql-java-kickstart:graphql-spring-boot-starter and the other is com.graphql-java:graphql-spring-boot-starter.
Which one should I choose?
These are different Starters (by different teams) providing different features, so there's no right or wrong answer. Here's a quick overview of what I'm aware is available:
The original starter made by the graphql-java team (com.graphql-java:graphql-spring-boot-starter) is now, I believe, defunct and superseded by the Spring GraphQL.
Spring GraphQL (org.springframework.boot:spring-boot-starter-web or org.springframework.boot:spring-boot-starter-webflux) is intended for schema-first development, is relatively simple and not very feature rich, but it's easy to use and works well with other Spring projects (like e.g. WebFlux and Spring Security).
If you want to go code-first (which I argue is still schema-first, just better), use graphql-spqr-spring-boot-starter, which will generate the GraphQL schema and an end-point for you, with no extra code needed. It's quickest way possible to expose Spring services. There's a sample project here. I'm the main author of that project, so this is a shameless plug, but I honestly believe it's lightyears ahead of other projects in terms of usability. The next version will be based on Spring GraphQL, so it should inherit most/all benefits as well (like e.g. RSocket support, which it currently lacks).
There's also DGS by Netflix (com.netflix.graphql.dgs:graphql-dgs-spring-boot-starter). It is also schema-first, has a plenty of features, but is also highly opinionated. I have no first-hand experience with it, but it is well documented, so you should have no problems finding what you need about it.
If you're already using graphql-java-tools (maintained by the Kickstart team), you'll likely want to go for com.graphql-java-kickstart:graphql-spring-boot-starter as they're intended to be used together. I have no clue how actively this project is maintained these days.

Lagom with Spring

Lagom by default uses Google Guice as implementation od DI pattern.
I would like to use Spring Framework instead.
Is it possible? IF so, how should it be done?
I have successfully integrated Akka with Spring (using hints from documentation and Internet), however I cannot find anything in documentation about integrating with Spring.
Possible? Yes. Will you be constantly swimming upstream, with reach upgrade break in new and unexpected ways requiring you to debug undocumented internal APIs? Most probably.
Lagom is built on Play, Play's DI support is ostensibly pluggable, when I wrote it I hacked together a proof of concept to ensure that Spring could be plugged into it. But it was only ever a proof of concept, neither I or the Play team ever had any desire or intention of maintaining it, so I published my work to GitHub:
https://github.com/jroper/play-spring
So that anyone for whom Spring support was important could continue where I left off. That was 3 years ago. In spite of a community of over a hundred thousand developers, no one ever took the work up. There's not a lot of work to do on the module itself, where most of the work would be is in Play and Lagom to fix areas where they have grown incompatible with Spring.
But really, why do you want to use Spring? The whole Lagom and Play ecosystems are built on Guice, saying you want to use Spring with Lagom is like saying you want to use a narrow gauge train in a country that only has standard guage rails, you're going to have to build yourself an entire new rail system to do so. What do you hope to achieve?

Reasons to use a persistence framework in Java EE?

I'm working on a Java EE Application, and I use Spring as framework.
Now I've seen people talking about ORM Frameworks (Hibernate/JPA/iBatis...) but I don't know what might be the reasons to use those frameworks?
I mean what those frameworks will change in the project functions & performance?
if you can give me a clear example it will be great.
Since you will get bored by writing the SQL insert/update/select statements for entire java objects and keep the Object <-> SQL code in shape when your object changes. JPA is actually a part of the Java EE standard.
However, it will not provide any means to keep you from knowing what you are doing with the database, except for very simple cases. My experience is that any JPA framework will add just another layer of complexity to performance issue track down and debugging.
In the end, you might end up need to understand how JPQL (SQL-ish syntax for JPA) translate into SQL for every combination of JPA provider (OpenJPA, HIbernate, eclipse link..) and datbase implementation. This will be non trivial.
If you have no specific performance requirements and just want easy object persistance, give it go! Hibernate seems to be state of the art atm.
To avoid writing your own SQL for everything, and to [partially] bridge the object-relational gulf ("abyss").
For simple requirements, ORMs are great, and make thinking about some DB stuff go away--with the caveat that you still need to be aware of what's actually happening on the DB side to prevent what can be serious performance implications.
For complicated requirements, you'll learn to understand why they call ORMs the "Vietname of computer science"... "We have learned the lessons of Vietnam... do not go to Vietnam."

Should i use the latest version of Spring

I am just starting to learn about spring and was looking at the difference between Spring 3.0 and Spring 2.5.
Initially i was following this tutorial http://static.springsource.org/docs/Spring-MVC-step-by-step/index.html which is a step by step guide to developing a Spring MVC application. It is based on Spring 2.5 and i notice there are quite a few differences with Spring 3.0. I tried to find the equivalent tutorial that is based on 3.0 but couldnt find it.
The difference i notice with 3.0 is that there is a lot of use of annotations and a lot of things is done for you in the background. I am sure this is a good thing but i am wondering for the purpose of learning the framework should i continue with 2.5 so that i can understand what goes on behind the scenes before i use spring 3.0?
Please also if you can recommend a spring book that is suitable for a beginner i would appreciate it.
Thanks
I'd recommend to always use the latest version of a framework. Especially if you're starting on a new project. There are always (well usually) tons of improvements, and simplifications, and migrating to the latest version later may be a pain.
Spring has a great user manual (see http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/), and IMHO a book doesn't have an added value in this case. I found the Spring user manual always easy to read and understand, so don't get intimidated. I think this is definitely the best starting for beginners as well. You don't have to read it all. Only the sections of interest!
Note that Spring 3.x contains many other improvements such as SpEL (Spring Expression Language), improved web support (you already saw that), REST support, and more.
... should i continue with 2.5 so that i can understand what goes on behind the scenes before i use spring 3.0?
That's really up to you to decide, but if you are going down the Spring 3.x annotation-based route, it is not clear that you >>need<< to understand what is happening behind the scenes. Especially for run-of-the-mill applications.
I was not aware of the purchase of Spring by VMware. Do you think this might affect the open source aspect of Spring in that it might not be open source anymore?
First, the SpringFramework guys are thoroughly committed to open source (from what I can see). So a change would probably entail lots of developers leaving.
Second, most of the people who use Spring do so because it is open source, so a change would risk a major migration of (paying) customers away.
Third, turning Spring into a closed source product would be a politically awful move for VMware, and would likely have fallout for other VMware product lines.
Finally, and most importantly for people committed to using Spring: there is no way that the VMware could legally "undo" the open sourcing of current Spring releases. The best they could do would be say that Spring 4.0 etc was closed source. Anyone who wanted to would be free to continue distributing and using SpringFramework 1.0.x, 2.0.x, 2.5.x, 3.0.x and all associated open sourced technologies. And anyone would be free to create a "fork" of any of them to continue Spring open source development. The only possible issue would be the use of trademarks, and that is easily worked around.
Add that all up, and (IMO) there is nothing to worry about.
"Spring in Action", "Pro Spring", and "Spring Recipes" are the three that I'd recommend to anyone.
If you've never used Spring, I'd say that learning either one will suit your purposes. The majority of Spring 2.5 carries over to 3.0, so it's not wasted.
The books and tutorials haven't kept up with Spring 3.0. Another change between versions was the purchase of Spring by VMWare. They've separated paid support from open source, so it's hard to tell what the future will be for non-paying customers.

Resources