1

I have an Person entity mapped here, inside this entity I have a set of roles (Set roles) mapped with JPA Annotations, ok... Well, I can't get the set of roles from this commmand using QueryDSL:

Set<Role> roles = query.from(qPerson).where(qPerson.login.eq(userName)).uniqueResult(qPessoa.roles);

Is that possible? What do you suggest? Thanks for all.


You can apply OOP principles to Javascript development too. Javascript uses prototypal inheritance, but that is an implementation detail. The concepts are still the same. Most of the concepts with which you are familiar have direct analogues in javascript.

Other tried and true methods apply as well:

1) Stay DRY -- Do not Repeat Yourself. Duplicate code is always evil.
2) Separate concerns -- Use the MVC or MVVM patterns to keep code clean and doing only 1 thing.
3) Test -- When I hear "Difficult to maintain" my brain translates that into lack of tests. You can certainly write unit tests for javascript projects.
4) Code Review -- Code reviews can be a good way of rejecting duplicated code, code that is not crafted properly, not formatted, etc....

4

1 回答 1

0

JPA 不支持这个,但是你可以使用下面的形式

query.from(qPerson).innerJoin(qPerson.roles, qRole)
  .where(qPerson.login.eq(userName))
  .list(qRole);
于 2012-03-22T06:10:17.353 回答