[
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
|
Confirmed, this is fixed in trunk. Thank you!
Gili
Christopher Delahunt wrote:
>
> What version are you using? Chances are you are hitting a bug fixed in
> the transaction for bug 247022 that caused the exception to be silently
> ignored - try the latest nightly.
>
> MySQL should be throwing an exception, something like
> "MySQLSyntaxErrorException: Table 'yourtable' doesn't exist", which will
> be wrapped in a
> org.eclipse.persistence.exceptions.DatabaseException Runtime exception
> type.
>
> Regards,
> Chris
>
>
>
> cowwoc wrote:
>> 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
>>>
>>>
>>>
>>
>>
> _______________________________________________
> 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-tp20667095p20671434.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.