/tests/com/google/appengine/datanucleus/test/HasOneToManyWithOrderByJPA.java

http://datanucleus-appengine.googlecode.com/ · Java · 89 lines · 53 code · 18 blank · 18 comment · 0 complexity · 373ec76bde5d60ed5b3ee84aa509e3e2 MD5 · raw file

  1. /**********************************************************************
  2. Copyright (c) 2009 Google Inc.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. **********************************************************************/
  13. package com.google.appengine.datanucleus.test;
  14. import java.util.ArrayList;
  15. import java.util.List;
  16. import javax.persistence.CascadeType;
  17. import javax.persistence.Entity;
  18. import javax.persistence.GeneratedValue;
  19. import javax.persistence.GenerationType;
  20. import javax.persistence.Id;
  21. import javax.persistence.OneToMany;
  22. import javax.persistence.OrderBy;
  23. /**
  24. * @author Max Ross <maxr@google.com>
  25. */
  26. @Entity
  27. public class HasOneToManyWithOrderByJPA {
  28. @Id
  29. @GeneratedValue(strategy=GenerationType.IDENTITY)
  30. private Long id;
  31. private String val;
  32. @OneToMany(cascade = CascadeType.ALL)
  33. @OrderBy("author DESC, title ASC")
  34. private List<Book> booksByAuthorAndTitle = new ArrayList<Book>();
  35. @OneToMany(cascade = CascadeType.ALL)
  36. @OrderBy("id DESC, author ASC")
  37. private List<Book> booksByIdAndAuthor = new ArrayList<Book>();
  38. @OneToMany(cascade = CascadeType.ALL)
  39. @OrderBy("author DESC, id ASC")
  40. private List<Book> booksByAuthorAndId = new ArrayList<Book>();
  41. public Long getId() {
  42. return id;
  43. }
  44. public List<Book> getBooksByAuthorAndTitle() {
  45. return booksByAuthorAndTitle;
  46. }
  47. public void setBooksByAuthorAndTitle(List<Book> booksByAuthorAndTitle) {
  48. this.booksByAuthorAndTitle = booksByAuthorAndTitle;
  49. }
  50. public List<Book> getBooksByIdAndAuthor() {
  51. return booksByIdAndAuthor;
  52. }
  53. public void setBooksByIdAndAuthor(List<Book> booksByIdAndAuthor) {
  54. this.booksByIdAndAuthor = booksByIdAndAuthor;
  55. }
  56. public List<Book> getBooksByAuthorAndId() {
  57. return booksByAuthorAndId;
  58. }
  59. public void setBooksByAuthorAndId(List<Book> booksByAuthorAndId) {
  60. this.booksByAuthorAndId = booksByAuthorAndId;
  61. }
  62. public String getVal() {
  63. return val;
  64. }
  65. public void setVal(String val) {
  66. this.val = val;
  67. }
  68. }