What is the best framework for developing a Java CRUD for an existent database?

Otavio picture Otavio · Jun 6, 2010 · Viewed 12.9k times · Source

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 this?

Answer

max-dev picture max-dev · Jul 13, 2013

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 );
        }
    };
}

}