zhangjingl02 / activejdbc

Automatically exported from code.google.com/p/activejdbc
0 stars 0 forks source link

Find related children from cache #105

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. create a new model class
2. add related model into cache by setChildren(Class,List)
3. find any cached children(without corresponding API)

What is the expected output? What do you see instead?

I think this is a common issue about the model function, the AJ does not 
support object operation and make something confuse to user, some operation 
won't affect DB, some operation will affect, and some other will throw 
exception.

What version of the product are you using? On what operating system?

1.1-SNAPSHOTS, MAX OS X

Please provide any additional information below.

I think the Model should add some instance methods such as:

  void addChild(Model) 
  void addChild(Class, Model)
  List getChildrenFromCache(Class)
  List findChildrenFromCache(Class klass, String query, Object... params)
  List findChildFromCache(Class klass, String query, Object...params)

at least, and integrate cache finding logic with origin Model#get(Class, query, 
params)

Original issue reported on code.google.com by kad...@gmail.com on 2 Aug 2011 at 11:14

GoogleCodeExporter commented 9 years ago
setting this as enhancement rather than defect. 

I'm not sure this is the right thing to implement. ActiveJDBC already has 
adding  and searching. Seems you are proposing to add objects in memory without 
saving them to DB?
If that is the case, then we would have to replicate DB logic in Java code for 
things like findChildrenFromCache(..). This would violate a DRY principle. 
Besides, there would be two methods for adding children: Model.add() and 
Model.addChild() - this will cause all kinds of confusion. Same for get(class) 
and getChildFromCache(klass). 
Why even expose this? 

Also, AJ has a query level cache anyway.
Theses APIs will be be hard to implement, very confusing and will provide 
little in way of ease of programming, 

sorry

Original comment by ipolevoy@gmail.com on 2 Aug 2011 at 2:56

GoogleCodeExporter commented 9 years ago
The case is I have a main object created, and it hasn't been saved to db, I 
want associate it with other children objects as a template objects graph for 
UI layer to fill, after UI submitted, it will be stored into DB.

I can understand your choice between simple and functionality, maybe I should 
maintain these temporary object in my domain model first, and summarize a 
pattern to deal with these cases.

Btw: ActiveRecord can support this case, do they have repeat them self for this 
feature?

Original comment by kad...@gmail.com on 3 Aug 2011 at 2:22

GoogleCodeExporter commented 9 years ago
understand the desire, but AJ does not have this at the moment. Adding a second 
set of APIs would seem strange, changing functionality of existing APIs will 
brake dependent projects. See if you can create a pattern of usage, and maybe 
can propose something better?

Original comment by ipolevoy@gmail.com on 3 Aug 2011 at 3:04

GoogleCodeExporter commented 9 years ago
I'm try to add some features, including transaction support, but I do not
have any oracle environment to meet your test requirements before commit, I
need some days to overcome this limitation.

Original comment by kad...@gmail.com on 3 Aug 2011 at 5:04

GoogleCodeExporter commented 9 years ago
sorry just noticed this comment, there is no rush, as you seem the only  one 
asking for this feature. If you install Oracle, I suggest Oracle XE. After 
that, you need to execute this inside any Oracle client:
ALTER SYSTEM SET PROCESSES=150 SCOPE=SPFILE

without this, Oracle will not work properly

Original comment by ipolevoy@gmail.com on 5 Aug 2011 at 6:26