~raginggoblin/infolog/infolog

« back to all changes in this revision

Viewing changes to InfologServer/lib/hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/hql/SimpleAssociatedEntity.java

  • Committer: Raging Goblin
  • Date: 2013-11-16 16:51:32 UTC
  • Revision ID: raging_goblin-20131116165132-weujnptzc88uy4ah
Mavenized the project, now using shared project InfologSync

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package org.hibernate.test.hql;
2
 
 
3
 
/**
4
 
 * @author Steve Ebersole
5
 
 */
6
 
public class SimpleAssociatedEntity {
7
 
        private Long id;
8
 
        private String name;
9
 
        private SimpleEntityWithAssociation owner;
10
 
 
11
 
        public SimpleAssociatedEntity() {
12
 
        }
13
 
 
14
 
        public SimpleAssociatedEntity(String name) {
15
 
                this.name = name;
16
 
        }
17
 
 
18
 
        public SimpleAssociatedEntity(String name, SimpleEntityWithAssociation owner) {
19
 
                this( name );
20
 
                bindToOwner( owner );
21
 
        }
22
 
 
23
 
        public Long getId() {
24
 
                return id;
25
 
        }
26
 
 
27
 
        public void setId(Long id) {
28
 
                this.id = id;
29
 
        }
30
 
 
31
 
        public String getName() {
32
 
                return name;
33
 
        }
34
 
 
35
 
        public void setName(String name) {
36
 
                this.name = name;
37
 
        }
38
 
 
39
 
        public SimpleEntityWithAssociation getOwner() {
40
 
                return owner;
41
 
        }
42
 
 
43
 
        public void setOwner(SimpleEntityWithAssociation owner) {
44
 
                this.owner = owner;
45
 
        }
46
 
 
47
 
        public void bindToOwner(SimpleEntityWithAssociation owner) {
48
 
                if ( owner != this.owner ) {
49
 
                        unbindFromCurrentOwner();
50
 
                        if ( owner != null ) {
51
 
                                owner.getAssociatedEntities().add( this );
52
 
                        }
53
 
                }
54
 
                this.owner = owner;
55
 
        }
56
 
 
57
 
        public void unbindFromCurrentOwner() {
58
 
                if ( this.owner != null ) {
59
 
                        this.owner.getAssociatedEntities().remove( this );
60
 
                        this.owner = null;
61
 
                }
62
 
        }
63
 
}