Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Joint Table not Mapper in Object Class #347

Closed
Bramiproject opened this issue May 29, 2020 · 7 comments
Closed

Joint Table not Mapper in Object Class #347

Bramiproject opened this issue May 29, 2020 · 7 comments

Comments

@Bramiproject
Copy link

How to Joint Table multiple object class ?

@mqus
Copy link
Collaborator

mqus commented May 29, 2020

I'm sorry, I really don't know what you want to do with the little information you gave. Please write more and/or give an example.

@Bramiproject
Copy link
Author

Bramiproject commented May 29, 2020

In Java / Kotlin Environment to do a Join Table using @Embedded annotation, but if in the Library floor use what annotation to map the Object Class ?

For the ex. in Java :

@Query("SELECT Foo.*, Bar.* FROM Foo INNER JOIN Bar ON Foo.bar = Bar.id")
List<FooAndBar> findAllFooAndBar();

public class FooAndBar {
    @Embedded
    Foo foo;

    @Embedded
    Bar bar;

    //Getter and setter...
}

Please help with this matter..
@mqus @vitusortner

@mqus
Copy link
Collaborator

mqus commented May 29, 2020

Well, that is easy to answer now :D

Currently, @embedded is not supported, but afaict it will be in the next version, thanks to @hsul4n s work in #328. But his is only a part of the things you will need so you may have to create a @DatabaseView with your query until we fully support arbitrary types as outputs from @Query functions. (Which we currently don't)

I can post an example here when the embedded function was added.

@Bramiproject
Copy link
Author

DatabaseView

Well, Thank you @mqus for your information 😃
I will wait for further information 🙏🏻

@Bramiproject
Copy link
Author

Bramiproject commented Jun 2, 2020

Hi @mqus,

Please your advice if use @DatabaseView how to using condition on Query in @DatabaseView ?

Ex.
`@DatabaseView(Select * From foo Where id = :id)

class Foo{
int Id;
Foo(Id)
}
`

@mqus
Copy link
Collaborator

mqus commented Jun 2, 2020

Parameters won't work in the declaration of a databaseview.

You have to include the parameter you want to compare with (e.g. id) in the select part of the query in the dbview and as a field of the view. You can then use it in the query method in the dao with WHERE id =:id. I'm on my phone right now so I can't show you a detailed example but you can try to take a look into the integration tests in floor/test/integration

@mqus
Copy link
Collaborator

mqus commented Jul 12, 2020

Closing as a duplicate of #9 and #94 . Please reopen if you disagree :)

@mqus mqus closed this as completed Jul 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants