Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » MongoDB queries throwing NPE
MongoDB queries throwing NPE [message #1075614] Mon, 29 July 2013 14:48 Go to next message
Peter Zeltins is currently offline Peter Zeltins
Messages: 8
Registered: July 2012
Junior Member
EL 2.4.2. I have a composite PU consisting of MySQL and Mongo PUs. MySQL one works fine, but whenever I try MongoDB query EL throws NPE:

Caused by: java.lang.NullPointerException
	at org.eclipse.persistence.nosql.adapters.mongo.MongoPlatform.extractValueFromExpression(MongoPlatform.java:468)
	at org.eclipse.persistence.nosql.adapters.mongo.MongoPlatform.appendExpressionToQueryRow(MongoPlatform.java:345)
	at org.eclipse.persistence.nosql.adapters.mongo.MongoPlatform.buildCallFromStatement(MongoPlatform.java:308)
	at org.eclipse.persistence.eis.EISDescriptor.buildCallFromStatement(EISDescriptor.java:536)
	at org.eclipse.persistence.internal.queries.StatementQueryMechanism.setCallFromStatement(StatementQueryMechanism.java:387)
	at org.eclipse.persistence.internal.queries.StatementQueryMechanism.prepareSelectAllRows(StatementQueryMechanism.java:312)
	at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.prepareSelectAllRows(ExpressionQueryMechanism.java:1701)
	at org.eclipse.persistence.queries.ReadAllQuery.prepareSelectAllRows(ReadAllQuery.java:721)
	at org.eclipse.persistence.queries.ReadAllQuery.prepare(ReadAllQuery.java:657)
	at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:614)
	... 45 more


The code running the query is:

		return em.createQuery("select f from " + WebFlowConversation.class.getName() + " f where f.buildNum != :buildNum",
				WebFlowConversation.class)
				.setParameter("buildNum", config.getBuildNumber())
				.getResultList();


Entity definition:

@Entity
@NoSql(dataFormat=DataFormatType.MAPPED,dataType="WebFlowConversation")
public class WebFlowConversation implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private String _id;
	private byte[] attributes;
	private String userName;
	private Date lastAccessTimestamp = new Date();
	private String buildNum;

	public WebFlowConversation() {
		
	}
	
	public WebFlowConversation(String idAsString, byte[] attributesAsByteArray, String userName) {
		this._id = idAsString;
		this.attributes = attributesAsByteArray;
		this.userName = userName;
	}

	@Field(name="_id")
	@Basic
	@Id
	public String getId() {
		return _id;
	}
	public void setId(String id) {
		this._id = id;
	}
	
	@Field
	//@Lob
	//@Basic(fetch=FetchType.LAZY)
	public byte[] getAttributes() {
		return attributes;
	}
	public void setAttributes(byte[] attributes) {
		this.attributes = attributes;
	}

	//@Column(name="username")
	@Field
	//@Basic
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	
	//@Column(name="accessed_time")
	@Field
	@Temporal(TemporalType.TIMESTAMP)
	//@Basic
	public Date getLastAccessTimestamp() {
		return lastAccessTimestamp;
	}
	public void setLastAccessTimestamp(Date lastAccessTimestamp) {
		this.lastAccessTimestamp = lastAccessTimestamp;
	}

	//@Column(name="build_num")
	@Field
	//@Basic
	public String getBuildNum() {
		return buildNum;
	}

	public void setBuildNum(String buildNum) {
		this.buildNum = buildNum;
	}
	
}


The underlying problem is that translationRow attribute on DatabaseQuery is null.

Am I doing something wrong here, or this is EL bug?
Re: MongoDB queries throwing NPE [message #1077403 is a reply to message #1075614] Thu, 01 August 2013 12:46 Go to previous messageGo to next message
John Bracken is currently offline John Bracken
Messages: 2
Registered: August 2013
Junior Member
Hi Peter. In your query, you do WebFlowConversation.class.getName(), which returns the package qualified name of the class. Is WebFlowConversation in the default package? If not, the package name being in the query would cause a problem. Just checking before I investigate this further.

Thanks, John
Re: MongoDB queries throwing NPE [message #1077527 is a reply to message #1077403] Thu, 01 August 2013 17:04 Go to previous message
Peter Zeltins is currently offline Peter Zeltins
Messages: 8
Registered: July 2012
Junior Member
John Bracken wrote on Thu, 01 August 2013 11:46
Hi Peter. In your query, you do WebFlowConversation.class.getName(), which returns the package qualified name of the class. Is WebFlowConversation in the default package? If not, the package name being in the query would cause a problem. Just checking before I investigate this further.

Thanks, John


All my classes are in named packages. Yes, the getName() returns package qualified name, and it works just fine if the same entity class is defined in RDBMS persistence unit (MySQL). I add package-qualified entity class names to my persistence.xml and set exclude-unlisted-classes to "true":


	<persistence-unit name="pu-nosql" transaction-type="RESOURCE_LOCAL">
		<class>my.package.WebFlowConversation</class>
		<exclude-unlisted-classes>true</exclude-unlisted-classes>


Thanks!
Peter
Previous Topic:MOXy: Override rules of binding files
Next Topic:Native query on MongoDB don't work with find
Goto Forum:
  


Current Time: Thu Jul 31 01:25:46 EDT 2014

Powered by FUDForum. Page generated in 0.02257 seconds