开发者

Should ORM / RDBMS be used with Java desktop applications? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

Closed 3 years ago.

Improve this question

I've been racking my brains on this one for a while. I've been living in the Django world for a while and it's hard to come back to Java.

I'm making a desktop Swing application t开发者_如何学运维hat does some straightforward CRUD stuff, with some simple one-to-many relations on the models. I've been looking at ORM solutions like DataNucleus, but I'm put off by its 20mb of dependencies, reliance on XML and my unfamiliarity with all the Three-Letter-Acronyms.

All I'm looking to do is let the user fill in some fields, display them in a table, let them select/edit/delete the entries in a table, and save/open that data to a file.

Are ORM solutions overkill for this type of scenario? Should I just put them all in an ArrayList and write all of the CRUD stuff myself?


All those frameworks are created for the express purpose of eliminating boiler plate and replacing it with stable code that has been tested to death. Whether you are talking about ORM for a RDBMS or mapping/binding frameworks for XML they are 'almost' never overkill. They serve to lower your application's risk profile. The key acronym is DRY.


DataNucleus 20Mb size of dependencies ? I'd suggest you revisit that and focus on your requirements. If you count up all of the possible datastore support and all of the possible dependencies of all of the possible datastore support you may get to 20Mb (but are you going to be persisting to 9 different types of datastores?), but then if you want to persist to say Excel using JDO you have less than 3Mb. And size of these jars has little or no bearing on speed of your app or much at all really (other than time to download, and internet connections are a bit faster than they used to be anyway).

Dependence on XML ? Nope. You can use annotations as you wish (and NO XML).


When you say "save/open that data to a file", what kind of a file is it? If XML, you could take a look to EclipseLink MOXy, which is a Object-XML-Mapper (JAXB implementation).


I would not not use RDBMS for a small desktop solution like you described. There are a lot of pretty tools to save data: custom-developed access with text files, serialized java objects, serialized portable data with protobuf.

If you want still to use SQL like access you can use SQL lite or embedded version of MYSQL.

Personally I did small order management app storing a collection of data in file on disk. You can also consider JSON format which must be familar for you based on your django background.


If you are using ORM(like JPA/Hibernate or other), some IDE(like Netbeans) has an ability to generate all classes that perform communication with database. All you need to do is to create a database schema(speaking in oracle's terminology). So after that you have only to write a business logic. If you don't want to use javaEE in your project you can use such tool as FireStormDAO. It can generate DAO classes from DDL script of your database.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜