Having a list of strings represented in a database using ORMLite?

First of all, List doesn't implement Serializable but ArrayList certainly does as well as most of the common collection implementations. But storing a huge list is probably not the best of doing this from a pure object model standpoint.

First of all, List doesn't implement Serializable but ArrayList certainly does as well as most of the common collection implementations. But storing a huge list is probably not the best of doing this from a pure object model standpoint. So why don't you want to have a table of all tags?

That's the best way from a pure model standpoint. It will require a 2nd query if you need them every time. That's the way hibernate would store a list or array of tags.

After reading your comment @creen, I still think you do want a table of tags. Your model class would then have: @ForeignCollectionField Collection tags; The tags table would not have a single tag named "red" with multiple model classes referring to it but multiple "red" entries. It would look like: model_id name 1 "red" 1 "blue" 2 "red" 3 "blue" 3 "black" Whenever you are removing the model object, you would first do a tags.clear(); which would remove all of the tags associated with that model from the tags table.

You would not have to do any extra cleanup or anything.

The reason for not wanting a table of tags is that my data is frequently changing. Removing an object with tags, I would for every tag it has, need to query for other objects with the same tags, if none is found I can remove the tag for the tags table. I think this is more work that what is needed for a simple list of tags.

But thanks for the heads-up on the Collections implementations. – creen May 14 at 9:47 Nice, I thought of the ForeignCollectionField as a ManyToMany relation, but as you put it, it is more like a OneToMany relation, which gives me peace to my mind :) Thanks for the update. – creen Aug 26 at 20:22.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions