Spring persistent framework which supports data class of kotlin - spring

the question is simple, but I can't find any of answer about this.
After searching, I realize that kotlin data class is not suitable for Spring JPA because data class is immutable and does not support inheritance.
So, I wonder are there any alternatives for JPA which support data class.
Thanks,

I find two kotlin-based ORM, ktorm and exposed.
It seems both are very good for start, and it supports data class.
But, at some point, I thought that I need to move to ktor rather than Spring boot when I wanna use kotlin more kotlin-tic way..

Related

Hexagonal Architecture with Hibernate Reactive and Quarkus

I am using Hexagonal Architecture, Hibernate Reactive with Panache and Quarkus in a Kotlin Project.
Transaction boundaries are set using #ReactiveTransactional annotation.
The problem is that I had to add the whole Hibernate Reactive with Panache dependency in the domain and application layers just to make this annotation available.
Is there a way to avoid this?
I was hoping it would be possible to create a domain annotation and then in the adapters layer replace it with the #ReactiveTransactional somehow.
You could remove the annotation from the class, and wrap it into a service, and implement this service in the adapter layer using the annotation.
Don't use database related dependencies inside the hexagon.
The idea is to decouple the business logic from the user interface and infrastructure. Database logic should be placed into an adapter.
It theory it sounds great, in practice that means tons of mappers i.e. boilerplate code. On the bright side you have a Kotlin, and not a Java project so this should be a bit less tedious than the alternative. Bear in mind that there are projects such as Dozer, MapStruct that can make the mapping process easier.

Use of Spring oxm

I am new to spring. I was looking into spring-oxm's XStreamMarshaller. I was hoping to find a way to convert my objects into xml using this. The spring site tells me clearly how to do it but it still needs me to add a XStream dependency in my POM. I don't understand what the use of spring-oxm is? If i had to add the xstream dependency anyway then i can directly use xstreams toXml operation and be done with it? I would really appreciate any help I could get in understanding the use of spring-oxm.
Thanks a lot in advance!
Spring provides a higher level abstraction for you by eliminating the scaffolding code you need to write. For e.g. in case of OXM you will be working with Marshaller and Unmarshaller abstractions irrespective of the underlying implementations uses (XStream, JAXB, Castor, XmlBeans etc). Moreover it lets you use DI for injecting marshalling/unmarshalling services to your own services. Another advantage is consistent exception hierarchy irrespective of the underlying implementation. All these are well explained on their reference documentation.
If you have very simple needs and doesn't already use Spring then I suggest you stick to JAXB that comes with JDK 6.

Spring Data JPA like project not dependent on Spring

Does anyone know any Java frameworks that follows the repository approach with automatic implementation of query methods (e.g. findByNameAndLastName(…)) but not tied to Spring, only pure JPA. Such feature also exists in GORM. I would like to see if there is any project that can be used in Guice or pure JavaEE environment without bringing Spring as a dependency.
(Disclaimer: I am the author of Spring Data JPA)
There is the CDI Query Module which is very similar to what Spring Data JPA. There's also a DeltaSpike module.
Note that Spring Data JPA ships with a CDI extension that creates repository proxies as plain CDI beans and does not bootstrap a Spring container. There are APIs that allow the creationg of repository proxies programmatically such as:
EntityManager em = // … obtain EntityManager
JpaRepositoryFactory factory = new JpaRepositoryFactory(em);
UserRepository repository = factory.getRepository(UserRepository.class);
Yes, it still requires Spring libraries to be present on the classpath but it is then using them similar to how you would use Commons Collection or the like. We try not to reinvent the wheel and the Spring libraries we depend on provide a lot of useful code that we do not have to re-code.
So if it's Spring as DI container you're worrying about, feel free to give the CDI extension of Spring Data JPA a choice. If you don't want to use any Spring whatsoever (for whatever reason), have a look at the alternatives.
Based on Oliver's information, followed up as also interested in this topic --
CDI Query joining Deltaspike mail thread: http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/Porting-the-CDI-Query-extension-project-to-DeltaSpike-td4329922.html
Deltaspike base link: http://deltaspike.apache.org/index.html
Getting started: http://deltaspike.apache.org/documentation.html
Just did their 0.4th release as of 5/31/2013.
However, have not done enough of a review to contrast/compare Deltaspike versus Spring-Data w/ CDI extensions (spring-data being very mature).
Take a look at Tomato on github!
It is a functional replacement for Spring JPA, has zero dependencies, performs better and is far easier to use. It will reduce your data access code by 98% and deliver the results you want right out of the box.
https://rpbarbati.github.io/Tomato.
If you want free, fully functional dynamic forms and/or tables for any Tomato entity or hierarchy, that can also be customized easily, try the angular based companion project...
https://rpbarbati.github.io/Basil
Both are current, maintained projects.
Try it yourself, or contact the author at rodney.barbati#gmail.com with questions.

Which class implements the spring roo repository interface

I am new to spring roo, and now, I am building a small project using spring roo 1.2.0.M1, and I fins=d that when I create a jpa repository using repository jpa, I only see the interface has been created, but I cannot find the class which implements that interface.
Another thing is I want to add #PersistenceContext to repository to specify which persistence context it should use. Because I cannot find the implement class, I cannot find out a way to do this.
If someone knows how to do this, please help me!
Thanks in advance!
This sounds like roo uses Spring Data JPA which works exactly that way: you define an interface using fixed name conventions, and at runtime the implementation proxy is generated for you based on the method name and return type (similar to the scaffolding approach of rails / grails).
Here's blog post that explains the mechanism:
GETTING STARTED WITH SPRING DATA JPA

Advantage of Spring

Spring is a popular framework, however I have difficulties to see in which situation the framework would actually help.
Currently I'm using the following:
* Tomcat
* Jersey
* Jackson
* Hibernate
Together this results in a Webservice, created by annotations, automatic JSON (un)marshalling and a comfortable Object/Relational Mapping.
So honestly at the moment I'm not missing anything, but I might just not know what great thing I'm missing... Could you help me out with this?
Thank you
Spring is a big framework providing a lot of functionality. It's hard to talk about advantages without knowing what functionality are you trying to use in the project.
Most probably you talk about Spring as an IoC container. It is very important part of Spring, but there is also AOP, transaction management, JDBC abstraction layer, authentication and authorization, testing and some more.
In a nutshell, Spring offers you uniform way to control dependencies between your objects. This is called inversion of control or dependency injection. Using it you can create pluggable, testable code that is easy to maintain.
In addition it gives you gazillion utility classes that just make life easier. For example, Hibernate is much easier to maintain via Spring facilities. It kind of brings together many different technologies under the same roof.

Resources