You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm new to Micronaut, please give me some advices ;)
I have an entity like this
@MappedEntity("accounts")
public class Account {
@Id
private ObjectId id;
@Relation(Relation.Kind.EMBEDDED)
private User owner;
// Which relation should I choose?
private List<User> managers;
......
}
and User is a nested object, not an entity.
@Embeddable
@Serdeable
public record User(String email, String name) {}
The criteria Page<Account> findByOwnerEmail(String, Pageable) compiles well. But Page<Account> findByManagersEmail(String, Pageable) does not. If I write the same annotation @Relation(Relation.Kind.EMBEDDED) on field managers, IDE will complain that List is not annotated with @Embeddable ( but I can't modify java.util.List). I want to find accounts by specific manager's email and paginate them. Which relation should I write on field managers? Maybe we need something like Relation.Kind.EMBEDDED_ARRAY? (In mongo shell, we can just type db.accounts.find({'managers.email': '[email protected]'}))
I'm using Java17, Gradle, Micronaut-core 3.9.1 and data 3.10.0.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm new to Micronaut, please give me some advices ;)
I have an entity like this
and User is a nested object, not an entity.
The criteria
Page<Account> findByOwnerEmail(String, Pageable)
compiles well. ButPage<Account> findByManagersEmail(String, Pageable)
does not. If I write the same annotation@Relation(Relation.Kind.EMBEDDED)
on fieldmanagers
, IDE will complain thatList
is not annotated with@Embeddable
( but I can't modify java.util.List). I want to find accounts by specific manager's email and paginate them. Which relation should I write on fieldmanagers
? Maybe we need something likeRelation.Kind.EMBEDDED_ARRAY
? (In mongo shell, we can just typedb.accounts.find({'managers.email': '[email protected]'})
)I'm using Java17, Gradle, Micronaut-core 3.9.1 and data 3.10.0.
Beta Was this translation helpful? Give feedback.
All reactions