Persisting Spring stateMachine in Database - spring

I understand that this question might be repeated but seems like previous answers are not adequate to provide clarity.
I want to save statemachine into database and rebuild statemachine using previously persisted stage.
My application is in Sprinng boot with JPA.
If I get any sample example that would be great.

There is a JpaStateMachineRuntimePersister that you can use.
Scroll all the way down to the bottom of the reference doc and you will find the link to:
https://docs.spring.io/spring-statemachine/docs/current/reference/

Related

Spring data JPARepository findById() on an Entity with #Version persists the record when no data is present for the primary key

Am using Spring Data JPA and hibernate in as springboot project for persistence, Whenever the method findyById() method on the Repository(JPA CRUD Repository) returns no data for the Primary key for an entity which uses #Version annotation for optimistic locking, it tries to insert an entity to the database.
I could see the insert query generated in the log file.
Has anyone come across such an issue? Please help.
The things I noticed from your explanation seem very strange to the program because this should not happen, you are just doing a simple query, it should not depend on the output of the query. Consider how much you have to look at different situations in very large application to avoid unexpected behaviors that cause problems.
One of the goals of ORM (Hibernate, etc.) is to ensure that the application meets your needs without worries.
There may be configuration on the side of your existing application that cause this problem.
In my opinion, to understand the problem, create another simple project with the minimum requirements, try again.

How to implement a snapshot system in Spring Boot application?

as I mentioned I want to implement a backup/snapshot feature for my web app.
As for details, imagine each User has several Projects which has several Components which also has several Subcomponents. Those are the entities that I want to backup apart from User.
The goal that I want to achieve is that user may save the current state as a snapshot and later if he doesn't like the new configuration, can easily turn back to his save and there can be multiple snapshots. Those snapshots has to be read only.
I'm asking for a design architecture or style or any kind of idea to implement. That's why I didn't put my entities here.
Thanks, beforehand!
I have some similar versioning in a project where I manage that in a service by simply introduced another entity. In your case that would be a ProjectVersion and the Project has a list (OneToMany) of these versions and additionally a ManyToOne (or OneToOne) relation to one ProjectVersion called master. The Project itself has no more fields.
A few days ago I stumbled across #Version from java persistence API (not the spring one) and this annotation should help to automatically increase and manage a version value in the entity during updates. But I haven’t tested it myself.

Spring Gemfire Cache implementation

I am trying to implement cache mechanism provide by Spring Data GemFire. Has anyone implemented a solution? I need to check on performance and ease to implement it.
Sonal-
First, you can find plenty of examples in the Spring User Guides, here, for example...
Accessing Data with GemFire,
Caching Data with GemFire, and ...
Accessing GemFire Data with REST
Additionally, there is a Spring GemFire Examples project here.
I have also started work on building a "Reference Implementation" (RI) for Spring Data GemFire/Geode, here. I have much work to do with this project yet, like documentation (READMEs) in the Repo, but I do plan to keep it up-to-date with my latest developments since I use the code as a basis for all my conference talks. Anyway, there is plenty of code examples and tests in this GitHub project to keep you busy for awhile.
Then, the Spring Data GemFire and Spring Data Geode GitHub projects themselves, have plenty of tests to show you how to address different application concerns (Configuration, Data Access, Function Execution, etc, etc).
Of particular interests might be the new Annotation-based configuration model for SDG^2 that I am working on. This is currently a WIP and I am also working on User Guide documentation for this feature/functionality, but it is established and even inspired by the auto-configuration features and Annotations provided by Spring and Spring Boot (e.g. #EnableXYZ).
Users have even started using the Annotation-based configuration model without significant documentation in place since it builds on concepts already available and familiar in Spring Boot. In fact combining these SDG specific Annotations with Spring Boot makes for a very powerful combination while preserving simple/easy nature to get started, 1 of my primary goals.
Given the lack of documentation yet, you can find more out in the Spring IO blog, where I first blogged about it here. Then I expanded on this article in a second blog, talking specifically about security.
And if you are really curious, you can follow the latest developments of the Annotation configuration model in my testing efforts.
Finally, of course, as I have already alluded to, as any good developer knows, getting started is as easy following the examples and reviewing Spring Data GemFire Reference Guide and Javadoc.
Don't forget to familiarize yourself with Pivotal GemFire as well! Javadoc here.
Hope this helps!
-John

Edit History on Database using Spring

I would like to know if a framework or a component (or even a Spring project!) exists that would allow me to save the history (automatically, or via #Java tags) of all edits done on a specific model object within my Spring project.
Thanks in advance,
Sammy
You are looking for a tool for auditing like Hibernate Envers. It works like a revision system for your DB entities.
Hibernate's integration with Spring is pretty straight forward, as well.
See also:
Hibernate Envers Docs

making changes to database with hibernate

so im quite new to all spring and hibernate so i used a feature in myeclipse called generate CRUD application (it uses spring and hibernate for the heart of the application and JSF for presentation objects)that im intended to make changes so that i can work with .. my question is the following .. after i made the application that works fine by the way , i discovered that there are fields and probably even tables to be added to the database(an oracle 11g instance database)..so my questions are the following:
if i create the classes and update the existing .. will it be written directly in the database?
if not is there any way to do it because i dont think a direct update in the database will be a good idea ..
thank you in advance ..
If I understand correctly, you want to know whether the database schema can be created/updated automatically from your #Entity classes, and how to enable/disable such creation. Yes, it's possible by using some property. The name of the property would depend on your project kind. For example, in a default Spring Boot application, you can have
spring.jpa.hibernate.ddl-auto: update
in application.properties. The value update above will have the schema automatically created on first run and then updated on subsequently. validate instead of update won't alter the schema, but just validate it.
This stackoverflow post lists the possible values and their behaviour.

Resources