I know that I can generate code based on my database schema using Hibernate, but that only creates models. Is there a way to generate base for DAO layer or Rest controllers? Most forum questions about this topic are years old and I couldn't find anything on IntelliJ web.
Thanks in advance!
You can use Telosys to generate a full rest backend (Controller, service and DAO layers) based on your database schema.
The advantage of using Telosys is that it provides a wide range of templates for most known languages and frameworks, and with few clicks you will have your full application ready.
Here is the wiki of how to use the command line interface : Telosys-CLI
In your case (Java) you can use this template to generate the rest controller layer :
Java web mvc spring
Java web rest jaxrs
You will need then the commons service layer :
Java commons
Java persistence commons
And for your DAO layer you will be able to chose between :
Java persistence JDBC
Java persistence JPA
Of course those are templates based on Java language, but Python and Node.JS are available as well.
Related
In PHP & Symfony world there is a tool called Sonata Admin https://sonata-project.org/ based on AdminLTE template, that is all-in-one admin tool with login, menu configuration, and what is most important - database tables HTML grid CRUD generators.
The tool saves you tons of efforts by avoiding you writing boilerplate code, moreover, there might be a scenario that you would write zero code.
We need the same but for Java and Spring stack. Any recommendations?
Take a look at JHipster project https://www.jhipster.tech/
With it you can create Spring Boot+Angular/React/Vue based applications. It provides some cool tools for generating CRUD entities by scaffolding.
https://www.javatpoint.com/spring-mvc-crud-example contains an example of how to create a Spring MVC CRUD there are plenty more examples of various spring project (This particular falls under Spring MVC).
This is not a ready-made CRUD, but a way how you could quickly implement one.
https://spring.io/guides/gs/crud-with-vaadin/ is also worth checking.
Although there are few project like spring batch admin (For batch administration), or Spring boot admin (Monitoring spring boot applications), which provides a UI, mainly spring project provides a simple programmatically way of plugging in what's needed.
It's a plug & play kind of framework which targets various aspects of an enterprise application. Chances of finding a ready-made UI app would be more on GitHub rather than a specific spring plugin.
Simple answer to your question is No spring does not provide any tool for that but spring gives you the functionalities that can reduce your work but not with zero coding.
example:
Using Spring Data JPA there is an Interface name curdRepository which
takes care of the curd Operations we dont need to implement the methods
for Curd Spring takes care of Curd operation.
Spring Security Provides the login configuration with the login form and logout mechanism.
You can use spring boot or just visit the https://start.spring.io/ it will initialize the spring project with the dependencies you need
I'm trying to create a Java Distributed Application, where i have two parts:
1) A Java EE running over Tomcat WebServer that have all business rules, JPA beans and crud operations. This part of architecture also have a RestFul layer that delegate all operations to a Service Layer, where all business lives.
2) A Java SE (Swing) that don't have any business logic and don't know JPA or any orm framework, a thin client. This just have Swing Forms and DTO (Data Transfer Object) Java Class. When this part need any database operation, it call Java EE RestFul (First part), passing DTO as JSON and this DTO is converted in Java Bean (JPA) in WebServer.
This is just a ideia of project but i have some doubts:
1) my biggest problem is convert DTO to Java Bean. I think this will be a trouble, because i need re-find the Bean in JPA (to attatch it in JPA PersistenceContext) and set property by property from DTO to JPA. There is any easy way to do it ? OBS: my dto is equal Java Bean but don't have JPA annotations. Is like a Class clone.
2) JSON is more faster way to Transfer data between RestFul?
3) can i control sessionScoped from Swing to Java EE ?
What I have,
I have a DB schema with 10 tables and basic relationships (one to one, one to many ) between the tables.
What I need,
I need to create webservices to access this DB Data (Lets ignore the business logic layer as of now) with basic CRUD operations
What I know,
I know we have JPA to generate entities, and jackson to map between json and POJO classes.
Now is there a tool which takes the DB Schema as input and generates the RESTful service classes, JPA entities with jackson annotations
Note:
We can use Spring to achieve most of it. But I dont want to use Spring or any J2EE framework for various other reasons.
I think NetBeans is the Best and the easiest.
Just right click on your web project and click on new as the picture
and if you want to create restfull web services from entity classes
Just right click on your entity classes package and click on new
Getting Started with RESTful Web Services
Have you considered JBoss Forge?
It's a tool that allows you, amongst many other things, to generate JPA entities from table and generate REST services as well (I've personally tested the JPA entities generation only). It doesn't rely on any framework, only on Java EE standard such as JPA and JAX-RS.
After creating the new project you have to call
jpa-generate-entities-from-table
to generate the entities (JPA classes) and then
rest-generate-endpoints-from-entities
to generate the REST endpoints.
In your case I think the IDE which you are using or you have option to use that is very important.
For MyEclipse
If you have option to use MyEclipse then you can expose JPA Entities via REST Web Services very easily without installing any plugins. Here is the link
Exposing JPA Entities via REST Web Services
Texo
You can also go for Texo if you think that is suitable for you
or if you are using Oracle WebLogic Server 12c (12.1.2) or later then
Oracle® Fusion Middleware Solutions will be a good choice
I would like to design and implement a mobile web application using JQuery mobile and Java EE technology.
The application will consists of sales persons using the mobile device to take an order when they visit the customers. So the application will contain complex business logic.
I am confused as to with what frameworks I should pick/select to design and implement the server side of the application. So my question is should I use Spring, Spring MVC and Hibernate together or some other suggestion?
But I want to stick to Java technology as I am comfortable with it.
My next question is how will the JQuery mobile and the server side integrate with each other. I mean what are the ways/methods to integrate them?
Your best bet would be to avoid Spring in this case.
Use straight Java EE, with JAX-RS, CDI/EJB and JPA.
Your jQuery code will call JAX-RS resources (which are ReSTfull web services). Those resources are injected with Service beans, which are a combination of CDI and EJB. These beans will contain your super complex business logic. If they need to retrieve or store something from/into the DB, they will use JPA for this via an injected entity manager.
I have implemented service layer which interacts with Data Access layer for data. So basically business logic is implemented at service layer. Services are implemented on spring framework. So basically each service can run on JBoss independently(as SAR). Now i want to implement presentation layer in smartGWT. So basically presenation layer code should call exposed methods of services for access of data. I want to know how well DataSource of smartGWT can integrate with a service and how to do same?
We did something similar. We put a Web layer on top of the Service layer. The Web layer contains Spring controllers that talk to SmartGWT (LGPL) RESTDataSources.
We've got it working nicely, but it's not a trivial task. The SmartGWT datasources are designed to integrate with the SmartGWT Pro libraries, which can make life tough if you're not using these. Make sure you understand the format of the requests/responses the datasources expect, see here:
SmartGWT RestDataSource
You'll probably find you have to customise the transformRequest() method on the datasource, see this question:
SmartGWT Datasource customization tutorial
We encountered a lot of problems with XPath support; basically it was fine for extracting data from complex objects sent to the datasource, but it was a nightmare trying to return complex objects in the correct format. We had to do a lot of work in transformRequest() to support this.
If you wish to use filtering, you will find yourself writing server code to interpret the Basic/Advanced Criteria objects SmartGWT sends.
You could also consider using Restlet, as mention in this question:
SmartGWT RestDataSource
In summary, you can do it and I encourage you to give it a go, but be prepared for a little work.