3

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

bcoughlan
  • 25,987
  • 18
  • 90
  • 141
  • Just to supplement this, I came across [JFace](http://wiki.eclipse.org/index.php/JFace), a library for helping with SWT, and supports MVC-style binding to tables while being independent of the type of persistence you're using. – bcoughlan Jun 23 '11 at 14:07

5 Answers5

4

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.

nsfyn55
  • 14,875
  • 8
  • 50
  • 77
1

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

dunni
  • 43,386
  • 10
  • 104
  • 99
1

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.

Vladimir
  • 4,782
  • 7
  • 35
  • 56
1

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.

maks
  • 5,911
  • 17
  • 79
  • 123
1

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

DataNucleus
  • 15,497
  • 3
  • 32
  • 37
  • Thanks for clearing that up. I have one small question: As I said the app has standard File->Open and File->Save capabilities. If I were to persist to an Excel file, would it persist to the file for every change I made to the model objects, or can it be done such that the model objects would stay in memory and only persist when the user clicks Save? – bcoughlan Jun 23 '11 at 14:14
  • Most logical way would be for File->Open to call the retrieve method on the persistence API, and for File->Save to call the save method on the persistence API. Persist/Retrieve calls take milliseconds so your user wouldn't notice them. At the end of the day, your code decides when you actually put the data in the datastore – DataNucleus Jun 23 '11 at 14:43