None of the Transient annotations are working with mongoDB data persistence.
Here are the annotations we used for the fields which should be skipped from persisting in mongo DB.
org.mongodb.morphia.annotations.Transient
com.google.code.morphia.annotations.Transient
org.springframework.data.annotation.Transient
javax.persistence.Transient
we even tried by directly adding transient keyword. transient privateTaxId taxId.
None of the above annotations are working. It's not skipping the value from getting persisted in Db.
We are using com.google.code.morphia.dao for persisting the objects. Here is our code base.
<dependency>
<groupId>org.mongodb.morphia</groupId>
<artifactId>morphia</artifactId>
<version>1.1.0</version>
</dependency>
org.mongodb.morphia.annotations.Transient is the only annotation supported by Morphia.
--
You received this message because you are subscribed to the Google Groups "Morphia" group.
To unsubscribe from this group and stop receiving emails from it, send an email to morphia+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<dependency>
<groupId>org.mongodb.morphia</groupId>
<artifactId>morphia</artifactId>
<version>1.1.1</version>
</dependency>
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlElement;
import org.mongodb.morphia.annotations.Transient;
public class UserInfo {
@XmlElement(name="name")
@Valid
@NotNull(message = "10003")
private Name name;
@XmlElement(name="address")
@Valid
@NotNull(message = "10004")
private Address address;
@XmlElement(name="phone")
@Valid
@NotNull(message = "10005")
private Phone phone;
@Transient
private TaxId taxId;
private DOB dob;
public UserInfo() {
super();
}
public UserInfo(Name name, Address address, Phone phone,TaxId taxId, DOB dob) {
this.name = name;
this.address = address;
this.phone = phone;
this.taxId = taxId;
this.dob =dob;
}
public Name getName() {
return name;
}
public void setName(Name name) {
this.name = name;
}
public Address getAddress() {
return address;
}
public void setAddress(Address address) {
this.address = address;
}
public Phone getPhone() {
return phone;
}
public void setPhone(Phone phone) {
this.phone = phone;
}
public DOB getDob() {
return dob;
}
public void setDob(DOB dob) {
this.dob = dob;
}
public TaxId getTaxId() {
return taxId;
}
public void setTaxId(TaxId taxId) {
this.taxId = taxId;
}
}
import org.mongodb.morphia.annotations.Transient;
public class TaxId {
@Transient
private String taxId;
@Transient
private String taxIdType;
public String getTaxId() {
return taxId;
}
public void setTaxId(String taxId) {
this.taxId = taxId;
}
public String getTaxIdType() {
return taxIdType;
}
public void setTaxIdType(String taxIdType) {
this.taxIdType = taxIdType;
}
}
...
--
...