mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-22 15:10:02 +00:00
#2153 - QueryBeans: OneToMany Map property is handled as PScalar instead of TQAssocBean
This commit is contained in:
1 parent
b3d439ed11
commit
ab9cdd8f5b
6 files changed
+78
-16
No files matched your search
@@ -1,8 +1,8 @@
|
||||
package org.example.domain;
|
||||
|
||||
import io.ebean.Model;
|
||||
import io.ebean.annotation.CreatedTimestamp;
|
||||
import io.ebean.annotation.UpdatedTimestamp;
|
||||
import io.ebean.annotation.WhenCreated;
|
||||
import io.ebean.annotation.WhenModified;
|
||||
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
@@ -11,10 +11,10 @@ import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* Base domain object with Id, version, whenCreated and whenUpdated.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Extending Model to enable the 'active record' style.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* whenCreated and whenUpdated are generally useful for maintaining external search services (like
|
||||
* elasticsearch) and audit.
|
||||
@@ -28,10 +28,10 @@ public abstract class BaseModel extends Model {
|
||||
@Version
|
||||
Long version;
|
||||
|
||||
@CreatedTimestamp
|
||||
@WhenCreated
|
||||
Timestamp whenCreated;
|
||||
|
||||
@UpdatedTimestamp
|
||||
@WhenModified
|
||||
Timestamp whenUpdated;
|
||||
|
||||
public Long getId() {
|
||||
|
||||
@@ -2,13 +2,10 @@ package org.example.domain;
|
||||
|
||||
import io.ebean.annotation.DbArray;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Contact entity bean.
|
||||
@@ -22,28 +19,32 @@ public class Contact extends BaseModel {
|
||||
|
||||
@Column(length=50)
|
||||
String firstName;
|
||||
|
||||
|
||||
@Column(length=50)
|
||||
String lastName;
|
||||
|
||||
|
||||
@Column(length=200)
|
||||
String email;
|
||||
|
||||
@Column(length=20)
|
||||
String phone;
|
||||
|
||||
|
||||
@ManyToOne(optional=false)
|
||||
Customer customer;
|
||||
|
||||
@OneToMany(mappedBy = "contact")
|
||||
List<ContactNote> notes;
|
||||
|
||||
@OneToMany(cascade = CascadeType.PERSIST)
|
||||
@MapKey(name="key")
|
||||
Map<String,ContactOther> others;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public Contact() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct with a firstName and lastName.
|
||||
*/
|
||||
@@ -51,7 +52,7 @@ public class Contact extends BaseModel {
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.example.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* Contact entity bean.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="be_contact_other")
|
||||
public class ContactOther extends BaseModel {
|
||||
|
||||
String key;
|
||||
|
||||
int something;
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public int getSomething() {
|
||||
return something;
|
||||
}
|
||||
|
||||
public void setSomething(int something) {
|
||||
this.something = something;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user