j256 / ormlite-android

ORMLite Android functionality used in conjunction with ormlite-core
http://ormlite.com/
ISC License
1.59k stars 366 forks source link

how to join two table? #139

Open iobsessu opened 2 years ago

iobsessu commented 2 years ago

now, i have a User object and a Role object , it look like this:

class User {
    private int id;
    private String username;
    private int roleId;
}
class Role {
    private int id;
    private String roleName;
}

i wanna know, how can i serialize it to

 {
    id: 10,
    name: "Jack",
    roleId: 20,
    roleName: "admin"
}

instead of

{
    id: 10,
    name: "Jack,
    role: {
        id: 20,
        roleName: "admin"
    }
}
pengcao1 commented 2 years ago
j256 commented 2 years ago

The short answer is that you can't without a lot of customization. Unfortunately, ORMLite right now does not support composite objects like this.