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

http://datanucleus-appengine.googlecode.com/ · Java · 79 lines · 50 code · 11 blank · 18 comment · 0 complexity · 6e9f9357b9d045b91fa3b532ceaa2e0e 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.List;
  15. import javax.persistence.CascadeType;
  16. import javax.persistence.Entity;
  17. import javax.persistence.FetchType;
  18. import javax.persistence.GeneratedValue;
  19. import javax.persistence.GenerationType;
  20. import javax.persistence.Id;
  21. import javax.persistence.OneToMany;
  22. import javax.persistence.OneToOne;
  23. import javax.persistence.SequenceGenerator;
  24. import javax.persistence.Table;
  25. import javax.persistence.UniqueConstraint;
  26. /**
  27. * @author Max Ross <maxr@google.com>
  28. */
  29. public class IgnorableMappingsJPA {
  30. @Entity
  31. public static class OneToManyParentWithEagerlyFetchedChildList {
  32. @Id
  33. @GeneratedValue(strategy=GenerationType.IDENTITY)
  34. public Long id;
  35. @SuppressWarnings("unused")
  36. @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
  37. private List<HasKeyPkJPA> children;
  38. }
  39. @Entity
  40. public static class OneToManyParentWithEagerlyFetchedChild {
  41. @Id
  42. @GeneratedValue(strategy=GenerationType.IDENTITY)
  43. public Long id;
  44. @SuppressWarnings("unused")
  45. @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
  46. private HasKeyPkJPA child;
  47. }
  48. @Entity
  49. @Table(uniqueConstraints = @UniqueConstraint(columnNames = "f1"))
  50. public static class HasUniqueConstraint {
  51. @Id
  52. @GeneratedValue(strategy=GenerationType.IDENTITY)
  53. public Long id;
  54. @SuppressWarnings("unused")
  55. private String f1;
  56. }
  57. @Entity
  58. public static class HasInitialSequenceValue {
  59. @SuppressWarnings("unused")
  60. @Id
  61. @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "yar")
  62. @SequenceGenerator(name = "yar", initialValue = 5)
  63. private Long id;
  64. }
  65. }