Spring Boot Jpa: Can I configure a JSON file as Database? [closed] - java

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I want to do CRUD operations on JSON file with JPA Repository.
I tried with JSON Populators as described by Baeldung.
But it is giving me org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory'.
Is there any other way I can do JPA operations without specifying any database with just on Json File?

Is there any Other way I can do JPA operation without specifying any database with just on Json File?
No.
JPA claims to be data source agnostic, but the only relevant implementations that actually exists are for relational databases only.
Repository populators are tools to load data from a resource and then use a repository to write them to a database.
They are typically used to initialise databases.
You can use different repositories (JPA, Mongo ...) to write to different types of database.
You could write your own Spring Data module reading and writing data to and from a JSON file, but no such implementation currently esxists as far as I know and it is probably not worth the effort for almost all scenarios.

Now if you're using Java, there is none, but if you're using Javascript, you can use lowdb, a JSON database.

Related

Retrieve Data From Database : Spring Boot [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed yesterday.
Improve this question
I understand that there are so many ways we can get data from the Db, one is using JPA or Typed/Named Query.
Wish to know on an Enterprise level do we use JpaRepository or custom repository and if custom what exactly do we use to fetch data is it Stream API or Criteria API or something else .
I have tried to use JpaRepository, getById() and also Stream API filter
I have been doing enterprise programming for a long time and the best choice for me was JPA because JPA allows you to avoid writing DML in the database specific dialect of SQL. JPA allows you to load and save Java objects without any DML language at all. When you do need to perform queries JPQL allows you to express the queries in terms of the Java entities rather than the (native) SQL tables and columns.
Also many helpful annotations like #DynamicUpdate and #DynamicInsert help ORM to create more efficient queries.

Spring batch meta data tables are not created in Cassandra database [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 days ago.
Improve this question
Need help on below
I did small task using spring batch with Cassandra database
Task : Reading data from Cassandra database and writing to file
Here when I check Cassandra data base Meta data tables are not getting created
Is spring batch will not crate meta data tables in Cassandra db ?
In Spring, schema creation is not enabled by default so no tables are created.
You didn't provide sufficient information in your question so it's hard to know whether this applies to your case. In any case, you need to explicitly configure schema creation, for example:
spring.data.cassandra.schema-action=CREATE_IF_NOT_EXISTS
For future reference, you need to provide minimal sample code which replicates the issue. Cheers!

Need to port Nodejs REST api server to a java api server [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have a nodejs server application that provides API. Due to some client issues, we need to implement the same server using java.
In node server, for GET or POST we simply execute SQL, GET or POST data to database using JSON.
But in Java, I have seen using spring boot, I have to create a Bean class and in my controller return a List in #GetMapping.
For all my APIs, I would have to create so many beans. Can I return data just like in nodejs, executing SQL query, getting and returning JSON data as it is in Java?
Also, if possible, is this approach recommended or the creating Bean approach is better? I am new to java so, have less idea about this.
I see nothing wrong in creating beans to transfer data from the database to consumer. I don't see any kind of performance or efficiency you would achieve by directly transferring data from SQL database to consumer using Spring MVC to send over HTTP, It even adds more complexity in Java specifically at persistence layer.
You should have been aware of that Java is verbose language before switching from NodeJS. It is better to create an equivalent POJOs.
If you still wanted to go with your own way of doing, following any of these existing posts you will achieve your expectation.
How to read/retrieve data from Database to JSON using JDBC?
Most efficient conversion of ResultSet to JSON?
Json object from database in java

configure rdf database for spring web mvc application [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
What is the best solution to configure rdf/owl database for spring web mvc applications?
I am searching a solution to orm for owl in spring application.
Have you looked into Stardog? I'm not sure what your exact goal is with the database, but this is what I use for creating/accessing/querying/etc. triple stores programmatically. They have an API called SNARL - here is a good example of how to use it with Java. They actually have a section in their docs for Spring Programming and use some different beans. I use a combination of the spring programming (for querying) and the method in the first link (for setting up dbs and loading files).
Downside is OWL/XML and Owl Functional Syntax are not supported file formats, but you can just convert your file to RDF/XML (esp. easy if you're using Protege). If you're not using Protege, there are other ways to do it.
If you have any further questions I'm happy to help out.

how to read data from excel and save into database using spring and hibernate [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
i have started learning spring, please help me about how to read data from excel and save into database using spring and hibernate, please show me
This question is not related to spring with hibernate.
To read data from excel you need to use a library like Apache POI.
Once you have the data in memory save them to the db using Spring with Hibernate as always (as you already tried with simple examples I hope).
Probably in 80% of the use cases it is possible (and actually easier as no implementation is required) to export the Excel sheet as CSV and import it using common database tools. There are a lot of infos in the internet how to import CSV, e.g. using COPY in Postgres or LOAD DATA in MySQL.

Categories

Resources