k0shk0sh / android-active-record Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/android-active-record
Automatically exported from code.google.com/p/android-active-record
Need to use normal Entity constructor to create an instance, not static method
of ActiveRecordBase.
Constructor must have mandatory parameter ActiveRecordBase
Original issue reported on code.google.com by Vladimir.Kroz
on 3 Aug 2010 at 8:48
Request for enhancement
Original issue reported on code.google.com by Vladimir.Kroz
on 18 Nov 2010 at 5:55
To insert a new record use code below:
MyObject n = _db.newEntity(MyObject.class);
EntitiesHelper.copyFieldsWithoutID(n, existObject);
n.save();
But how i update the same record after insert it?
Original issue reported on code.google.com by [email protected]
on 13 Feb 2013 at 8:23
What steps will reproduce the problem?
1. create an entity with a sql.Timestamp field
2. give it a date
3. do a .save
4. read the entity with the findAll function
What is the expected output? What do you see instead?
The Timestamp fields contains a wrong value
What version of the product are you using? On what operating system?
r147
Please provide any additional information below.
if in the file ActiveRecordBase.java you add these lines; it seems to start
working fine:
=if (column.getType().getSuperclass() == ActiveRecordBase.class)
= values.put(CamelNotationHelper.toSQLName(column.getName()),
= column.get(this) != null ? String
= .valueOf(((ActiveRecordBase) column
= .get(this))._id) : "0");
+else if (column.getType().toString().equals("class +java.sql.Timestamp"))
+ values.put(CamelNotationHelper.toSQLName(column.getName()),
+ String.valueOf(((Timestamp)column.get(this)).getTime()));
=else
= values.put(CamelNotationHelper.toSQLName(column.getName()),
= String.valueOf(column.get(this)));
Original issue reported on code.google.com by [email protected]
on 2 Jun 2011 at 6:54
I am new user of this library. So excuse me, if I am wrong and please correct
me. I found that one of main library usecases: persistance(saving) is quite
ugly in use. To persist User object I need to make 3 calls:
User u = new User("szaman", "haslo");
User newU = db.newEntity(User.class);
EntitiesHelper.copyFieldsWithoutID(newU, u);
newU.save();
Why not introduce some simplier solution. Some "one-line-save" solution. For
example:
package com.dendryt.bicyk.android.model;
import org.kroz.activerecord.ActiveRecordBase;
import org.kroz.activerecord.ActiveRecordException;
import org.kroz.activerecord.EntitiesHelper;
public class ActiveRecordBaseExt extends ActiveRecordBase{
public <T extends ActiveRecordBase> T copyEntity(T obj, ActiveRecordBase db) throws ActiveRecordException{
T newEntity = (T) db.newEntity(obj.getClass());
EntitiesHelper.copyFieldsWithoutID(newEntity, obj);
return newEntity;
}
public void saveAsNewObject(ActiveRecordBase db) throws ActiveRecordException{
copyEntity(this, db).save();
}
}
Now etity class should extend ActiveRecordBaseExt and saving it is prepared by
one call:
User u = new User("szaman", "haslo");
u.saveAsNewObject(dbb);
I am new user of this library. So excuse me, if I am wrong and please correct
me. I found that one of main library usecases: persistance(saving) is quite
ugly in use. To persist User object I need to make 3 calls:
User u = new User("szaman", "haslo");
User newU = db.newEntity(User.class);
EntitiesHelper.copyFieldsWithoutID(newU, u);
newU.save();
Why not introduce some simplier solution. Some "one-line-save" solution. For
example:
package com.dendryt.bicyk.android.model;
import org.kroz.activerecord.ActiveRecordBase;
import org.kroz.activerecord.ActiveRecordException;
import org.kroz.activerecord.EntitiesHelper;
public class ActiveRecordBaseExt extends ActiveRecordBase{
public <T extends ActiveRecordBase> T copyEntity(T obj, ActiveRecordBase db) throws ActiveRecordException{
T newEntity = (T) db.newEntity(obj.getClass());
EntitiesHelper.copyFieldsWithoutID(newEntity, obj);
return newEntity;
}
public void saveAsNewObject(ActiveRecordBase db) throws ActiveRecordException{
copyEntity(this, db).save();
}
}
Now etity class should extend ActiveRecordBaseExt and saving it is prepared by
one call:
User u = new User("szaman", "haslo");
u.saveAsNewObject(dbb);
I am looking forward for some feedback from you:)
Original issue reported on code.google.com by [email protected]
on 11 Feb 2011 at 3:45
What steps will reproduce the problem?
1. Create two new entities that are of the same type. (entity1, entity2)
2. Insert entity1, then modify one of it's values
3. Save entity1 and entity2 and look at their return values
What is the expected output? What do you see instead?
entity1 will return 1 since that is how many rows were affected. Meanwhile
entity2 will return a different value (say 1000) since that is it's rowId in
the database.
Instead we should see that on save() of entity2 that it should return the total
number of rows since every row was affected.
What version of the product are you using? On what operating system?
Please provide any additional information below.
This is just from looking at the code while working on making some mocks. I
can work on some test cases to make this fail if you would like.
Original issue reported on code.google.com by [email protected]
on 21 Jan 2011 at 2:43
at ActiveRecordBase.java append:
private static final String[] countProjection = new String[]{"count(*)"};
/**
* count table
* @param <T>
* @param type
* @return
* @throws ActiveRecordException
*/
public <T extends ActiveRecordBase> long count(Class<T> type,String where,String[] whereArgs) throws ActiveRecordException {
if (m_Database == null)
throw new ActiveRecordException("Set database first");
T entity;
try {
entity = type.newInstance();
} catch (IllegalAccessException e) {
throw new ActiveRecordException(e.getLocalizedMessage());
} catch (InstantiationException e) {
throw new ActiveRecordException(e.getLocalizedMessage());
}
Cursor c = m_Database.query(entity.getTableName(), countProjection, where, whereArgs);
try {
c.moveToFirst();
return c.getLong(0);
} finally {
c.close();
}
}
Original issue reported on code.google.com by [email protected]
on 1 Dec 2010 at 4:52
a simple space
Original issue reported on code.google.com by [email protected]
on 12 Dec 2011 at 12:00
Attachments:
Hi, just started to use your active record - very handy library.
It's early days for my app, and I'm changing the DB schema frequently. I forgot
to update the database schema number, so insert failed. But it did it silently
- no exception was thrown.
In ActiveRecordBase.insert() I'd recommend it throws an exception if the id
returned in -1 at the end of the method. See below.
What do you think?
Cheers,
James
public long insert() throws ActiveRecordException {
List<Field> columns = _id > 0 ? getColumnFields()
: getColumnFieldsWithoutID();
ContentValues values = new ContentValues(columns.size());
for (Field column : columns) {
try {
if (column.getType().getSuperclass() == ActiveRecordBase.class)
values.put(
CamelNotationHelper.toSQLName(column.getName()),
column.get(this) != null ? String
.valueOf(((ActiveRecordBase) column
.get(this))._id) : "0");
else
values.put(CamelNotationHelper.toSQLName(column.getName()),
String.valueOf(column.get(this)));
} catch (IllegalAccessException e) {
throw new ActiveRecordException(e.getLocalizedMessage());
}
}
_id = m_Database.insert(getTableName(), values);
if (-1 != _id)
m_NeedsInsert = false;
return _id;
}
Original issue reported on code.google.com by [email protected]
on 3 Jan 2011 at 7:44
What steps will reproduce the problem?
1. Include the tests in your Android test project
2. Run the tests as an Android JUnit Test
3. See the test fail
What is the expected output? What do you see instead?
junit.framework.AssertionFailedError: expected:<2> but was:<4>
at org.kroz.activerecord.EntityTest.testCreateEntity(EntityTest.java:82)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at
android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:43
0)
at
android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)
What version of the product are you using? On what operating system?
Product Version - Trunk
Android OS - 2.1-update1
Please provide any additional information below.
Included is a patch that fixes this issue.
Original issue reported on code.google.com by [email protected]
on 19 Jan 2011 at 9:21
Attachments:
Add a new project with AR usage examples
Original issue reported on code.google.com by Vladimir.Kroz
on 3 Aug 2010 at 8:51
Hi.
I've created a patch of 'getColumnFields'.
This can get column fields from super class, even if the class is not a direct
sub class of ActiveRecordBase.
Would you merge this ?
Original issue reported on code.google.com by atsn.ngs
on 14 Dec 2010 at 8:33
Attachments:
What steps will reproduce the problem?
1. Have two classes where one can have a list of the other (ex. Keychain, Key)
2. Use a List to store to the to-many objects (List<Key> keys)
3. Try to run a test with these objects
What is the expected output? What do you see instead?
java.lang.IllegalArgumentException: Class cannot be stored in Sqlite3 database.
at org.kroz.activerecord.Database.getSQLiteTypeString(Database.java:381)
at org.kroz.activerecord.DatabaseBuilder.getSQLCreate(DatabaseBuilder.java:90)
at org.kroz.activerecord.DatabaseOpenHelper.onCreate(DatabaseOpenHelper.java:42)
at
android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.ja
va:106)
at
android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.ja
va:158)
at org.kroz.activerecord.Database.open(Database.java:136)
at org.kroz.activerecord.ActiveRecordBase.open(ActiveRecordBase.java:58)
at
com.shopify.mobileandroid.test.product.ProductTest.setUpDatabase(ProductTest.jav
a:65)
at com.shopify.mobileandroid.test.product.ProductTest.setUp(ProductTest.java:55)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at
android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:43
0)
at
android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)
What version of the product are you using? On what operating system?
android-active-record - Trunk
android 2.1-update1
Please provide any additional information below.
It would be nice to have the class gracefully handle the creation of an
intermediate table to store the relationship between the classes.
Would the use of annotations make this easier?
ie. @HasMany(class = Keys.class, name="keys")
Original issue reported on code.google.com by [email protected]
on 20 Jan 2011 at 7:26
What steps will reproduce the problem?
1. Create a new entity that has some elements in it like phoneNumber1 and
phoneNumber2
2. Add this class to the DatabaseBuilder
3. Try to create your database. An exception will get throw
What is the expected output? What do you see instead?
You will get an error similar to the following:
E/Database( 2068): Failure 1 (duplicate column name: OPTION) on 0x11d668 when
preparing 'CREATE TABLE PRODUCT_VARIANT (_id integer primary key, UPDATED_AT
int, CREATED_AT int, FULFILLMENT_SERVICE text, TITLE text, SKU text,
INVENTORY_MANAGEMENT text, INVENTORY_POLICY text, OWNER int, OPTION text,
OPTION text, OPTION text, INVENTORY_QUANTITY int, POSITION int, PRICE real,
PRODUCT_ID int, REQUIRES_SHIPPING bool, ID int, TAXABLE bool, GRAMS int,
COMPARE_AT_PRICE real)'.
What version of the product are you using? On what operating system?
Android 2.1-update1
AAR - trunk
Please provide any additional information below.
Attached is a patch which fixes the issue along with tests to replicate the
issue and prove that the problem has been resolved.
Original issue reported on code.google.com by [email protected]
on 24 Jan 2011 at 9:51
Attachments:
Need to add developer's guide pages to project wiki
Original issue reported on code.google.com by Vladimir.Kroz
on 3 Aug 2010 at 8:49
Complete set of unit-tests
Original issue reported on code.google.com by Vladimir.Kroz
on 3 Aug 2010 at 8:50
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.