Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Query.getResultList() returns null if the table does not exist

I am using MySQL. I did "drop database Foo; create database Foo;" and re-ran
my application. It worked fine up until this code returned null:

	@Transactional(rollbackOn = Exception.class)
	public List<Terminal> listTerminals()
	{
		Query query = em.get().createQuery("select terminal from " +
Terminal.class.getSimpleName() +
			" as terminal");
		@SuppressWarnings("unchecked")
		List<Terminal> result = query.getResultList();
		return result;
	}

PS: Throwing SQLException seems a bit contrived. The Javadoc says only
IllegalStateException may be thrown and as far as I know SQLException is a
checked exception.

Gili


Christopher Delahunt wrote:
> 
> I don't understand how you are not getting an exception if the table 
> does not exist.  Can you show how you create and execute the query?
> Running on an Oracle DB, I get a SQLException: ORA-00942: table or view 
> does not exist. 
> 
> Best Regards,
> Chris
> 
> 
> 
> cowwoc wrote:
>> Ooops, "empty set" should read "empty list".
>>
>> Gili
>>
>>
>> cowwoc wrote:
>>   
>>> I am expecting it to return an empty set as per "Effective Java" best
>>> practices. I'd like to file a bug report for this. What do you think?
>>>
>>> PS: Anyone working on JPA 2.0 should please clarify the Javadoc on this
>>> point.
>>>
>>> Gili
>>>
>>>     
>>
>>   
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> 
> 

-- 
View this message in context: http://www.nabble.com/Query.getResultList%28%29-returns-null-if-the-table-does-not-exist-tp20667095p20667698.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top