[EoDsql-users] Adding elements to a (disconnected) DataSet
Status: Beta
Brought to you by:
lemnik
|
From: Ricardo P. <rpm...@ya...> - 2007-06-22 19:19:36
|
Hi, First of all, thank you for the 0.9 beta release, Jason. The site new look is nicer, too. At this moment I have in my program some classes whose persistence I wrote before I know about EoDSQL, and I want to change that so all of them use EoDSQL. Up to now, every entity in my database model has two Java classes (three where EoDSQL is not yet used): - ASimpleClass - ASimpleClassList ASimpleClass represents a single element, whereas ASimpleClassList implements or extends things like MutableComboBoxModel or AbstractListModel. This way, I have an easy way to put GUI controls (JList, JComboBox, etc.) to access to the underlying database table. I've even dared to use DataSet as the in-memory list view of the database table (I'm using tables with very few rows, 10 or so). Now, in a specific entity (VERSION, which represents versions of products and could have a UNIQUE constraint on product + version fields) I have the need to add a "fake" element, like a "*" wildcard. It will be used in a JComboBox and won't be persisted in the VERSION table. To put some context on the why I need it, I have another table "ROLES" managing permissions, in which I want to be able to have rows like: Row Meaning -------------------------------------------------------- 1 UserA is owner of productA, version 1.0 2 UserB is owner of productA, version 1.5 3 UserA is translator of productB, version 2.0 4 UserB is owner of productB, version * as a quick way to make userB owner of every possible version of productB (row 4), instead of requiring a new row every time a new version of productB is created and, at the same time, allow different users to be owners of different versions of the same product (rows 1 & 2). Obviously, the "*" fake element in the VERSION in-memory list would be used in a JComboBox in the ROLES management window. Now, I'm not really sure if I could simply add an element to the DataSet in disconnected mode and use it in the JComboBox model like a simple List. I never write back the DataSet to disk; every time a record is added, modified or deleted, the query is re-executed and the DataSet is disconnected. I *believe* I may be in the safe side, but I don't really know for sure. Is this a sensible approach? TIA |