1

community.

I am just start to use droidparts. As I got it is cool library. But it has poor documentation, and no comments in code itself. I am interested in getting elegant approach to use it.

Well suppose, i've created tables items, users, items2users as many-to-many concept. Tables items and users are trivial. Table items2users is

@Table(name="items2users")
public class ItemsToUsers extends Entity {
    @Column
    public Item item;
    @Column
    public User user;
}

So if I need to get answer if my User has Item I do something like that in UserManager class:

public boolean hasItem(Item item) {
    Select<ItemsToUsers> select = select().columns(ID).where({HERE_I_NEED_COLUMN_NAME}, Is.EQUAL, user.id);   
}

Droidparts made table with fields 'item_id' and 'user_id'. As I understand HERE_I_NEED_FIELD_NAME must be 'user_id'. As I realize it is automatic naming model for this situation? Well is there some elegant technique to achive this names or I should construct them manually getting 'user' and '_' and 'id'?

Valery Kulikov
  • 319
  • 1
  • 12

1 Answers1

0

By default the column name will be field name + _id, e.g. item_id & user_id in your case. That can be altered through annotation, e.g. @Column(name="some_other_name").

yanchenko
  • 56,576
  • 33
  • 147
  • 165