forked from ebean-orm/ebean
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master-rob' into master-new
- Loading branch information
Showing
11 changed files
with
262 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
ebean-test/src/test/java/org/tests/cache/embeddedid/Concept.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.tests.cache.embeddedid; | ||
|
||
import javax.persistence.*; | ||
import java.util.List; | ||
|
||
@Entity | ||
@IdClass(ConceptId.class) | ||
@SuppressWarnings("unused") | ||
public class Concept { | ||
@Id | ||
private String id; | ||
|
||
@Id | ||
private String networkId; | ||
|
||
private String label; | ||
|
||
@OneToMany(mappedBy = "from", cascade = {CascadeType.ALL}) | ||
private List<Connection> outgoingConnections; | ||
|
||
@OneToMany(mappedBy = "to", cascade = {CascadeType.ALL}) | ||
private List<Connection> incomingConnections; | ||
|
||
public Concept(String networkId, String id, String label) { | ||
this.networkId = networkId; | ||
this.id = id; | ||
this.label = label; | ||
} | ||
|
||
public String id() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public String networkId() { | ||
return networkId; | ||
} | ||
|
||
public void setNetworkId(String networkId) { | ||
this.networkId = networkId; | ||
} | ||
|
||
public String label() { | ||
return label; | ||
} | ||
|
||
public void setLabel(String label) { | ||
this.label = label; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
ebean-test/src/test/java/org/tests/cache/embeddedid/ConceptId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.tests.cache.embeddedid; | ||
|
||
import javax.persistence.Embeddable; | ||
|
||
@Embeddable | ||
public class ConceptId { | ||
private final String networkId; | ||
private final String id; | ||
|
||
public ConceptId(String networkId, String id) { | ||
this.networkId = networkId; | ||
this.id = id; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
ConceptId conceptId = (ConceptId) o; | ||
if (!id.equals(conceptId.id)) return false; | ||
return networkId.equals(conceptId.networkId); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = id.hashCode(); | ||
result = 31 * result + networkId.hashCode(); | ||
return result; | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
ebean-test/src/test/java/org/tests/cache/embeddedid/Connection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package org.tests.cache.embeddedid; | ||
|
||
import javax.persistence.*; | ||
|
||
@Entity | ||
@IdClass(ConceptId.class) | ||
@SuppressWarnings("unused") | ||
public class Connection { | ||
@Id | ||
private String id; | ||
|
||
@Id | ||
private String networkId; | ||
|
||
private String label; | ||
|
||
@ManyToOne(optional = false) | ||
@JoinColumns({ | ||
@JoinColumn(name = "from_conc", referencedColumnName = "id", nullable = false), | ||
@JoinColumn( | ||
name = "network_id", referencedColumnName = "network_id", | ||
nullable = false, insertable = false, updatable = false | ||
) | ||
}) | ||
private Concept from; | ||
|
||
@ManyToOne(optional = false) | ||
@JoinColumns({ | ||
@JoinColumn(name = "to_conc", referencedColumnName = "id", nullable = false), | ||
@JoinColumn( | ||
name = "network_id", referencedColumnName = "network_id", | ||
nullable = false, insertable = false, updatable = false | ||
) | ||
}) | ||
private Concept to; | ||
|
||
public Connection( | ||
String networkId, String id, String label, | ||
Concept from, Concept to | ||
) { | ||
this.networkId = networkId; | ||
this.id = id; | ||
this.label = label; | ||
this.from = from; | ||
this.to = to; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public String getNetworkId() { | ||
return networkId; | ||
} | ||
|
||
public void setNetworkId(String networkId) { | ||
this.networkId = networkId; | ||
} | ||
|
||
public String getLabel() { | ||
return label; | ||
} | ||
|
||
public void setLabel(String label) { | ||
this.label = label; | ||
} | ||
|
||
public Concept from() { | ||
return from; | ||
} | ||
|
||
public void setFrom(Concept from) { | ||
this.from = from; | ||
} | ||
|
||
public Concept to() { | ||
return to; | ||
} | ||
|
||
public void setTo(Concept to) { | ||
this.to = to; | ||
} | ||
} |
Oops, something went wrong.