为现有数据库开发 Java CRUD 的最佳框架是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2984688/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 23:49:32  来源:igfitidea点击:

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

javaframeworkscrud

提问by Otavio

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?

我们有一个 Java 应用程序,在数据库 (Oracle) 上有很多配置表。我们希望使用基于 Web 的 GUI 来设置这些表,我们目前通过 SQL 查询更新这些表。为我们的数据库子集开发 CRUD 的最简单方法是什么?是否有任何基于 Java 的框架来执行此操作?

回答by max-dev

IMHO, there is quite a good solution for managing application data without need to write any additional code.

恕我直言,有一个很好的解决方案来管理应用程序数据,而无需编写任何额外的代码

LightAdminis 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.

LightAdmin是一个用于 Spring/JPA 支持的应用程序的可插入 Java 库,它通过干净简单的 UI 提供标准的 CRUD 功能、过滤、JSR-303 验证。它提供用于接口定制的 DSL,您可以随时将其从应用程序中插入/拔出。

Here is a small example of DSL configuration customization:

下面是一个DSL配置定制的小例子:

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

}

回答by John T

Telosys Tools( http://www.telosys.org/) has been design for this kind of job.

Telosys Tools( http://www.telosys.org/) 就是为这种工作而设计的。

It uses an existing database to generate source code (typically CRUD screens) And it's possible to customize the templates if necessary

它使用现有的数据库来生成源代码(通常是 CRUD 屏幕)并且可以在必要时自定义模板

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 )

尝试它的最佳方法是遵循教程:https: //sites.google.com/site/telosystutorial/
(有一个适用于 Spring MVC / Spring Data / JPA 的堆栈)

See also : http://marketplace.eclipse.org/content/telosys-tools

另见:http: //marketplace.eclipse.org/content/telosys-tools

回答by Dolph

Grailsis basically"Java on Rails," and the scaffolding behaves exactly as you would expect.

Grails基本上是“Java on Rails”,并且脚手架的行为完全符合您的预期。

回答by Florian

reinCRUDis a vaadinadd-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 toolsfor example) to generate Hibernate entities and then place annotations for reinCRUD on them.

reinCRUD是一个vaadin插件,它使用带注释的休眠实体工作。您可以在几分钟内创建一个 CRUD 应用程序,并且可以重用列表、表单和搜索表单等组件。在我们的例子中,您可以使用 DB 建模工具(例如休眠工具)来生成休眠实体,然后在它们上放置 reinCRUD 的注释。

回答by KevinM

Depending on your existing database design, you could consider Apache Isis.

根据您现有的数据库设计,您可以考虑Apache Isis

Apache Isis is best suited for running your entire application, so it is possibly overkill for just managing portions of your dataset.

Apache Isis 最适合运行您的整个应用程序,因此仅管理部分数据集可能有点过分。

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.

但是对于其他任何寻求完整解决方案的人来说——基于 Web 的 GUI(Wicket 和 2 个自定义 HTML 版本)、完整的数据库后端支持(现在支持 JDO)和 POJO 的运行时内省(Isis 不是代码生成器) ,也许这对你有用。

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).

Apache Isis SQL 对象存储(使用 JDBC)可以配置为将现有表映射到您的类,将表列映射到您的类属性(您可以覆盖属性文件中自动分配的名称)。

For larger projects, perhaps the JDO datastore is more appropriate, and is configured with annotations.

对于较大的项目,也许 JDO 数据存储更合适,并且配置了注释。

I am a contributor and a member of the Apache Isis PMC - with special focus on the SQL object store.

我是 Apache Isis PMC 的贡献者和成员 - 特别关注 SQL 对象存储。

回答by amelvin

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!).

我认为使用 ORM 工具可以更轻松地生成 CRUD。最近有一个关于Java ORM 的关于 SO 的问题——Hibernate获得了最多的选票(尽管没有使用排名相当高的 ORM!)。