Generating simple crud applications in Spring based off existing database or hibernate configurations?
Asked Answered
U

9

8

I'm attempting to learn Spring MVC but have been spoiled by Grails. While I am able to get a basic web application working I was wondering if there were any tools that could do some of the work to create a crud application given a database or hibernate data model? The only one I've found so far is http://www.skywayperspectives.org/portal/web/guest/downloads/overview I'm not sure how to take the generated code and convert it to use either maven or ant for it's build process.

Urion answered 2/12, 2009 at 15:42 Comment(1)
I'll just leave this here in case anyone is interested in open source CRUD generators: github.com/topics/crud-generator?l=javaJointed
M
3

I've never tried it but it looks like the Appfuse Maven Plugin (AMP) allows you to do this via Maven. There's a mvn appfuse:gen-model command to reverse engineer from a database and mvn appfuse:gen to create the rest of the scaffold.

I think you have to run these from within a project created with one of the Appfuse Maven archetypes. You can find the quickstart guide here to set that up.

Spring Roo has some nice scaffolding too, but it doesn't have the reverse engineering from the database you're looking for yet. Your persistence objects need to be annotated as @RooEntity objects before you can take advantage of the scaffolding with that framework.

Morty answered 3/12, 2009 at 1:24 Comment(1)
I can't get the generate command to work in App Fuse but have looked at Spring Roo. I've decided to use Spring Roo, my database is simple enough that i can manually create all the necessary entities. I really like Spring Roo, although I don't know if I'd use it for a production app yet since it still appears to be lacking good documentation but I assume this will be fixed in the 1.0 release. Also database reverse engineering is listed as a high priority feature request.Urion
M
4

Telosys does this job : http://www.telosys.org

If you have a database it will use it as a model to generate the code (JPA entities, etc)

Standard templates bundles are available to generate a fully operational web application with CRUD screens

Metaphysical answered 30/4, 2014 at 15:40 Comment(0)
M
3

I've never tried it but it looks like the Appfuse Maven Plugin (AMP) allows you to do this via Maven. There's a mvn appfuse:gen-model command to reverse engineer from a database and mvn appfuse:gen to create the rest of the scaffold.

I think you have to run these from within a project created with one of the Appfuse Maven archetypes. You can find the quickstart guide here to set that up.

Spring Roo has some nice scaffolding too, but it doesn't have the reverse engineering from the database you're looking for yet. Your persistence objects need to be annotated as @RooEntity objects before you can take advantage of the scaffolding with that framework.

Morty answered 3/12, 2009 at 1:24 Comment(1)
I can't get the generate command to work in App Fuse but have looked at Spring Roo. I've decided to use Spring Roo, my database is simple enough that i can manually create all the necessary entities. I really like Spring Roo, although I don't know if I'd use it for a production app yet since it still appears to be lacking good documentation but I assume this will be fixed in the 1.0 release. Also database reverse engineering is listed as a high priority feature request.Urion
S
3

Just follow this tutorial: https://sites.google.com/site/telosystutorial/

It will generate a full Web App based on Spring MVC / Spring Data / JPA

Slub answered 14/4, 2014 at 13:16 Comment(0)
W
1

Try springfuse

Warrenwarrener answered 29/5, 2011 at 16:45 Comment(1)
The site says, SpringFuse no longer operates but… Celerio the code generator that was powering SpringFuse is now Open Source.Jointed
W
1

Looks like LightAdmin pluggable administration interface for Spring/JPA based applications would be a good choice for you. It has a built-in Java DSL for interface configuration and the only thing you need to do is to download a jar or declare Maven dependency, enable your domain administration through web.xml (point to package containing your JPA entities) and create @Administration configuration class for the entity.

As a result you will have a clean and simple UI for CRUD, filtering, etc.

Here is an example of configuration:

@Administration( Customer.class )
public class CustomerAdministration {

  public static EntityMetadata configuration(EntityMetadataBuilder configurationBuilder ) {
    return configurationBuilder.nameField( "firstname" ).build();
  }

  public static ScreenContext screenContext( ScreenContextBuilder screenContextBuilder ) {
    return screenContextBuilder
           .screenName( "Customers Administration" )
           .menuName( "Customers" ).build();
  }

  public static FieldSet listView( final FieldSetBuilder fragmentBuilder ) {
    return fragmentBuilder
           .field( "firstname" ).caption( "First Name" )
           .field( "lastname" ).caption( "Last Name" ).build();
  }
Wildfowl answered 13/7, 2013 at 22:0 Comment(1)
This project looks promising, but is it supported? The latest commit on GitHub was two years ago. It seems to be more dead than alive.Jointed
T
0

I have made the same search. Finally had a look at JBoss Seam. Seam appears to have a database schema import and generates the necessary backend and frontend code. Spring Roo seams to be very similar to JBoss Seam, just that Seam is longer there and more mature.

Timeless answered 18/12, 2009 at 9:31 Comment(0)
B
0

If you want to learn spring MVC with reverse-engineering there is minuteproject track REST-SpringMVC

It 'smart' reverse engineer your db schema, provides

  • JPA2
  • AO w/ spring integration
  • spring MVC and REST integration

Smart reverse-engineering means that your Java entities does not have to follow your DB convention (Ex table T_USER can give Java User class...)

Buxom answered 10/9, 2013 at 20:14 Comment(0)
A
0

You can take a look at crud-rest-gen project which explains how to use the crud-maven-plugin to generate :

  • the CRUD Rest API
  • the documentation of the API
  • the AngularJS CRUD Administration UI
  • the Rest API for retrieving audit information and associated unit tests if you use Hibernate Envers to audit your entities.

All you need to provide is the data model containing the JPA entities.

Many samples are provided, based on the Spring PetClinic data model.

Annal answered 13/11, 2016 at 21:46 Comment(0)
J
0

Take a look at Celerio. Here's a link to template Angular 2 + PrimeNG + Spring Boot web application.

Celerio is a code generator tool for data-driven application. It can reverse a database schema and generate advanced CRUD-based applications.

The following screencast shows you what to expect.

Jointed answered 12/12, 2017 at 23:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.