ormlite-android icon indicating copy to clipboard operation
ormlite-android copied to clipboard

Wrote Complete: Support Multi-DB within OpenHelperManager. Need PR?

Open jiongxuan opened this issue 10 years ago • 4 comments

Hi! I'm a Ormlite fan. We have many projects that use your products. Thanks a million!

Note: My English is not good. So I would speak as briefly as possible and use simple words.

Before

We used to refer your example HelloAndroidTwoDbs to suppport multi-db.

In addition, lacking any better idea :-(

After

Later, I tried to modify OpenHelerManager.

I created two new classes: OpenHelper and OpenHelpers. The role of OpenHelper is almost the same as the original OpenHelperManager, except became into a instance. OpenHelpers is used to manage all of the OpenHelper.

Just like:

Dao<City, Long> dao = OpenHelpers.getDao(context, CityHelper.class, City.class);
OpenHelpers.release(CityHelper.class);

These OrmLiteSqliteOpenHelper(s) match the ones all over the New OpenHelper(s). Fully comply with the rules!

Other usage:

CityHelper helper = OpenHelpers.getOrmliteHelper(context, CityHelper.class);
OpenHelper openHelper = OpenHelpers.get(CityHelper.class);

Advantage

It's very fruitful. These classes has approached the issue in a practical way. You won't need to reference any example, rewrite any extra code. Just need to use that one.

Testing

I wrote some simple unit-test code, have long time for our project. All operators have to verify is passed, ease of use!

Ending

If @j256 want to use these code, please tell me. I will improve the unit test, and PR to your project.

Awaiting for your reply. Thank you very much!

CC: @VincentFTS @emmby

jiongxuan avatar Nov 14 '14 15:11 jiongxuan

Sorry for the delay on this. Did you come up with a generic solution? We are getting ready to [finally] push 4.49 and I'd like to see if we can add support for this to 4.49 or maybe 4.50 which should come out soon after.

j256 avatar Jan 29 '15 01:01 j256

I also think we should support this, so the users do not have to write the solution which is in your examples, introducing potential bugs if they are not careful.

WonderCsabo avatar Jun 10 '15 10:06 WonderCsabo

@jiongxuan , did you send anything to @j256 ?

VincentJousse avatar Jun 19 '15 09:06 VincentJousse

haha 5.0 already support!!

WillCoder avatar Dec 06 '16 16:12 WillCoder