-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from emmanuelbernard/embeddable
[jpa] Add support for @embeddable, @Embedded, superclass and interfaces
- Loading branch information
Showing
7 changed files
with
248 additions
and
15 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
examples/strict/src/main/java/org/jboss/shamrock/example/jpa/Address.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,37 @@ | ||
package org.jboss.shamrock.example.jpa; | ||
|
||
/** | ||
* This is an enmarked @Embeddable class. | ||
* Let's see if just being referenced by the main entity is enough to be detected. | ||
* | ||
* @author Emmanuel Bernard [email protected] | ||
*/ | ||
public class Address { | ||
private String street1; | ||
private String street2; | ||
private String zipCode; | ||
|
||
public String getStreet1() { | ||
return street1; | ||
} | ||
|
||
public void setStreet1(String street1) { | ||
this.street1 = street1; | ||
} | ||
|
||
public String getStreet2() { | ||
return street2; | ||
} | ||
|
||
public void setStreet2(String street2) { | ||
this.street2 = street2; | ||
} | ||
|
||
public String getZipCode() { | ||
return zipCode; | ||
} | ||
|
||
public void setZipCode(String zipCode) { | ||
this.zipCode = zipCode; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
examples/strict/src/main/java/org/jboss/shamrock/example/jpa/Animal.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,16 @@ | ||
package org.jboss.shamrock.example.jpa; | ||
|
||
/** | ||
* @author Emmanuel Bernard [email protected] | ||
*/ | ||
public class Animal { | ||
private double weight; | ||
|
||
public double getWeight() { | ||
return weight; | ||
} | ||
|
||
public void setWeight(double weight) { | ||
this.weight = weight; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,17 +1,23 @@ | ||
package org.jboss.shamrock.example.jpa; | ||
|
||
import javax.persistence.Embedded; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Id; | ||
|
||
/** | ||
* Used to test reflection references for JPA | ||
* | ||
* @author Emmanuel Bernard [email protected] | ||
*/ | ||
@Entity | ||
public class Customer { | ||
public class Customer extends Human { | ||
@Id | ||
// no getter explicitly to test field only reflective access | ||
private Long id; | ||
|
||
private Address address; | ||
private WorkAddress workAddress; | ||
|
||
private String name; | ||
|
||
public String getName() { | ||
|
@@ -21,4 +27,22 @@ public String getName() { | |
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
// Address is referenced but not marked as @Embeddable | ||
@Embedded | ||
public Address getAddress() { | ||
return address; | ||
} | ||
|
||
public WorkAddress getWorkAddress() { | ||
return workAddress; | ||
} | ||
|
||
public void setWorkAddress(WorkAddress workAddress) { | ||
this.workAddress = workAddress; | ||
} | ||
|
||
public void setAddress(Address address) { | ||
this.address = address; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
examples/strict/src/main/java/org/jboss/shamrock/example/jpa/Human.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,21 @@ | ||
package org.jboss.shamrock.example.jpa; | ||
|
||
import javax.persistence.MappedSuperclass; | ||
|
||
/** | ||
* Mapped superclass test | ||
* | ||
* @author Emmanuel Bernard [email protected] | ||
*/ | ||
@MappedSuperclass | ||
public class Human extends Animal { | ||
private String name; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} |
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
21 changes: 21 additions & 0 deletions
21
examples/strict/src/main/java/org/jboss/shamrock/example/jpa/WorkAddress.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,21 @@ | ||
package org.jboss.shamrock.example.jpa; | ||
|
||
import javax.persistence.Embeddable; | ||
|
||
/** | ||
* Class marked @Embeddable explicitly so it is picked up. | ||
* | ||
* @author Emmanuel Bernard [email protected] | ||
*/ | ||
@Embeddable | ||
public class WorkAddress { | ||
private String company; | ||
|
||
public String getCompany() { | ||
return company; | ||
} | ||
|
||
public void setCompany(String company) { | ||
this.company = company; | ||
} | ||
} |
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