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

http://datanucleus-appengine.googlecode.com/ · Java · 62 lines · 33 code · 11 blank · 18 comment · 0 complexity · da5124dcb6c10c095fb308c6a7ccff3f MD5 · raw file

  1. /**********************************************************************
  2. Copyright (c) 2011 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.HashSet;
  15. import java.util.Set;
  16. import javax.jdo.annotations.IdGeneratorStrategy;
  17. import javax.jdo.annotations.PersistenceCapable;
  18. import javax.jdo.annotations.Persistent;
  19. import javax.jdo.annotations.PrimaryKey;
  20. import com.google.appengine.datanucleus.annotations.Unowned;
  21. /**
  22. * "Owner" of a 1-N unidirectional relation in JDO, using unowned relations.
  23. */
  24. @PersistenceCapable(detachable="true")
  25. public class UnownedJDOOneToManyUniSideA {
  26. @PrimaryKey
  27. @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  28. Long id;
  29. @Persistent
  30. @Unowned
  31. Set<UnownedJDOOneToManyUniSideB> others = new HashSet<UnownedJDOOneToManyUniSideB>();
  32. String name;
  33. public Long getId() {
  34. return id;
  35. }
  36. public void setName(String name) {
  37. this.name = name;
  38. }
  39. public String getName() {
  40. return name;
  41. }
  42. public void addOther(UnownedJDOOneToManyUniSideB other) {
  43. this.others.add(other);
  44. }
  45. public Set<UnownedJDOOneToManyUniSideB> getOthers() {
  46. return others;
  47. }
  48. }