I have a collection in MongoDB named IMAGE.files.
And, I have an Entity class, called Image:
@Entity
@NoSql(dataFormat=DataFormatType.MAPPED,dataType="IMAGE.files")
public class Image {
@Id
@GeneratedValue
@Field(name="_id")
private String id;
@Field(name="filename")
private String filename;
public Image() {
super();
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getFilename() {
return filename;
}
public void setFilename(String filename) {
this.filename = filename;
}
}
Here is the code snippet of the query function:
TypedQuery<Image> query = em.createQuery("SELECT o FROM Image o WHERE o.filename = :filename", Image.class);
query.setParameter("filename", filename);
result = query.getResultList();
The function is executed without errors. However, EclipseLink selects a wrong collection, files, for querying. The correct one should be IMAGE.files.
[EL Fine]: sql: 2015-12-17 15:53:41.939--ServerSession(1371385683)--Connection(1930844915)--Thread(Thread[[ACTIVE] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Executing MappedInteraction()
spec => null
properties => {mongo.operation=FIND, mongo.collection=files}
input => [DatabaseRecord(
IMAGE.files.filename => Penguins.jpg)]
I suspect that the problem is caused by the dataType in @NoSql annotation. It seems that EclipseLink does not allow a dot in the dataType.
Any help is appreciated.
Thanks.