What is the best framework for developing a Java CRUD for an existent database?
We have a Java application with lots of config tables on the database (Oracle). We'd like to have Web-based GUIs for setting up these tables, that we currently update via SQL queries. What is the simplest way to develop CRUDs for a subset of our database? Is there any Java-based framework for doing thi开发者_C百科s?
IMHO, there is quite a good solution for managing application data without need to write any additional code.
LightAdmin is a pluggable Java library for Spring/JPA backed applications, which provides standard CRUD functionality, filtering, JSR-303 validation through clean and simple UI. It provides DSL for interface customization and you can plug/unplug it from your application whenever you want.
Here is a small example of DSL configuration customization:
@Administration( Booking.class )
public class BookingAdministration {
public static ScopesConfigurationUnit scopes( final ScopesConfigurationUnitBuilder scopeBuilder ) {
return scopeBuilder
.scope( "All", all() )
.scope( "Smoking Apartments", specification( smokingApartmentsSpec( true ) ) )
.scope( "Non Smoking Apartments", specification( smokingApartmentsSpec( false ) ) )
.scope( "Long-term bookings", filter( longTermBookingPredicate() ) ).defaultScope().build();
}
public static FiltersConfigurationUnit filters( final FiltersConfigurationUnitBuilder filterBuilder ) {
return filterBuilder
.filter( "Customer", "user" )
.filter( "Booked Hotel", "hotel" )
.filter( "Check-In Date", "checkinDate" ).build();
}
public static FieldSetConfigurationUnit listView( final FieldSetConfigurationUnitBuilder fragmentBuilder ) {
return fragmentBuilder
.field( "user" ).caption( "Customer" )
.field( "hotel" ).caption( "Hotel" )
.field( "checkinDate" ).caption( "Check-In Date" )
.field( "smoking" ).caption( "Smoking" )
.field( "beds" ).caption( "Beds" )
.build();
}
public static DomainTypePredicate longTermBookingPredicate() {
return new DomainTypePredicate() {
@Override
public boolean apply( final Booking booking ) {
return booking.getNights() > 20;
}
};
}
public static DomainTypeSpecification smokingApartmentsSpec( final boolean isSmokingApartment ) {
return new DomainTypeSpecification() {
@Override
public Predicate toPredicate( final Root root, final CriteriaQuery<?> query, final CriteriaBuilder cb ) {
return cb.equal( root.get( "smoking" ), isSmokingApartment );
}
};
}
}
Telosys Tools ( http://www.telosys.org/ ) has been design for this kind of job.
It uses an existing database to generate source code (typically CRUD screens) And it’s possible to customize the templates if necessary
The best way to try it is to follow the tutorial: https://sites.google.com/site/telosystutorial/
(there’s a stack for Spring MVC / Spring Data / JPA )
See also : http://marketplace.eclipse.org/content/telosys-tools
Grails is basically "Java on Rails," and the scaffolding behaves exactly as you would expect.
I think that using an ORM tool makes generating CRUDs easier. There is a recent question on SO concerning Java ORMs - which came out with Hibernate getting the most votes (although not using an ORM ranked fairly high!).
reinCRUD is a vaadin add-on which works using annotated hibernate entities. You can create a CRUD application within a few minutes and you can re-use components like lists, forms and search forms. In our case you could use a DB modelling tool (hibernate tools for example) to generate Hibernate entities and then place annotations for reinCRUD on them.
Depending on your existing database design, you could consider Apache Isis.
Apache Isis is best suited for running your entire application, so it is possibly overkill for just managing portions of your dataset.
But for anyone else looking for a total solution - with Web-based GUIs (Wicket and 2 custom HTML versions), full database back-end support (now with JDO support) and runtime introspection of your POJOs (Isis is not a code generator), perhaps this could work for you.
The Apache Isis SQL object store (which uses JDBC) can be configured to map existing tables to your classes and table columns to your class properties (you can override the automatically assigned names in the properties files).
For larger projects, perhaps the JDO datastore is more appropriate, and is configured with annotations.
I am a contributor and a member of the Apache Isis PMC - with special focus on the SQL object store.
精彩评论