mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#542 - ENH: @DbJson fields are auto serialized and deserialized to specified classes.
This commit is contained in:
@@ -7,8 +7,10 @@ import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Version;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Entity
|
||||
@@ -19,6 +21,18 @@ public class EBasicJsonList {
|
||||
|
||||
String name;
|
||||
|
||||
@DbJson(length = 700)
|
||||
Set<PlainBean> beanSet;
|
||||
|
||||
@DbJson(length = 700)
|
||||
List<PlainBean> beanList;
|
||||
|
||||
@DbJson(length = 700)
|
||||
Map<String,PlainBean> beanMap = new LinkedHashMap<String, PlainBean>();
|
||||
|
||||
@DbJson(length = 500)
|
||||
PlainBean plainBean;
|
||||
|
||||
@DbJson(length = 50)
|
||||
Set<Long> flags = new LinkedHashSet<Long>();
|
||||
|
||||
@@ -60,6 +74,38 @@ public class EBasicJsonList {
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
public PlainBean getPlainBean() {
|
||||
return plainBean;
|
||||
}
|
||||
|
||||
public void setPlainBean(PlainBean plainBean) {
|
||||
this.plainBean = plainBean;
|
||||
}
|
||||
|
||||
public Set<PlainBean> getBeanSet() {
|
||||
return beanSet;
|
||||
}
|
||||
|
||||
public void setBeanSet(Set<PlainBean> beanSet) {
|
||||
this.beanSet = beanSet;
|
||||
}
|
||||
|
||||
public List<PlainBean> getBeanList() {
|
||||
return beanList;
|
||||
}
|
||||
|
||||
public void setBeanList(List<PlainBean> beanList) {
|
||||
this.beanList = beanList;
|
||||
}
|
||||
|
||||
public Map<String, PlainBean> getBeanMap() {
|
||||
return beanMap;
|
||||
}
|
||||
|
||||
public void setBeanMap(Map<String, PlainBean> beanMap) {
|
||||
this.beanMap = beanMap;
|
||||
}
|
||||
|
||||
public Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.avaje.tests.model.json;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* Something for Jackson ObjectMapper to marshall.
|
||||
*/
|
||||
public class PlainBean {
|
||||
|
||||
String name;
|
||||
|
||||
long along;
|
||||
|
||||
Timestamp timestamp;
|
||||
|
||||
public PlainBean(String name, long along) {
|
||||
this.name = name;
|
||||
this.along = along;
|
||||
this.timestamp = new Timestamp(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
/**
|
||||
* A constructor for Jackson.
|
||||
*/
|
||||
public PlainBean() {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "name:" + name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getAlong() {
|
||||
return along;
|
||||
}
|
||||
|
||||
public void setAlong(long along) {
|
||||
this.along = along;
|
||||
}
|
||||
|
||||
public Timestamp getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(Timestamp timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user