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

http://datanucleus-appengine.googlecode.com/ · Java · 65 lines · 36 code · 11 blank · 18 comment · 2 complexity · 5f9f7155824b92ad9c5e237d4d361acb 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 bidirectional relation in JDO, using unowned relations.
  23. */
  24. @PersistenceCapable(detachable="true")
  25. public class UnownedJDOOneToManyBiSideA {
  26. @PrimaryKey
  27. @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  28. Long id;
  29. @Persistent(mappedBy="related")
  30. @Unowned
  31. Set<UnownedJDOOneToManyBiSideB> others;
  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(UnownedJDOOneToManyBiSideB other) {
  43. if (this.others == null) {
  44. this.others = new HashSet<UnownedJDOOneToManyBiSideB>();
  45. }
  46. this.others.add(other);
  47. }
  48. public Set<UnownedJDOOneToManyBiSideB> getOthers() {
  49. return others;
  50. }
  51. }