|
View:
New views
9 Messages
—
Rating Filter:
Alert me
|
|
|
Query.getResultList() returns null if the table does not existI 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 |
|
|
Re: Query.getResultList() returns null if the table does not existOoops, "empty set" should read "empty list".
Gili
|
|
|
Re: Query.getResultList() returns null if the table does not existI 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@... https://dev.eclipse.org/mailman/listinfo/eclipselink-users |
|
|
RE: Query.getResultList() returns null if the table does not existGili,
If you are referring to Item 27: "Return zero-length arrays, not nulls" of Guy Steele's excellent book, we will reread page 134 - keeping lazy initialization and the spec in mind and advise. thank you /michael -----Original Message----- From: cowwoc [mailto:cowwoc@...] Sent: Monday, November 24, 2008 13:49 To: eclipselink-users@... Subject: Re: [eclipselink-users] Query.getResultList() returns null if the table does not exist 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 > -- View this message in context: http://www.nabble.com/Query.getResultList%28%29-returns-null-if-the-table-does-not-exist-tp20667095p20667107.html Sent from the EclipseLink - Users mailing list archive at Nabble.com. _______________________________________________ eclipselink-users mailing list eclipselink-users@... https://dev.eclipse.org/mailman/listinfo/eclipselink-users _______________________________________________ eclipselink-users mailing list eclipselink-users@... https://dev.eclipse.org/mailman/listinfo/eclipselink-users |
|
|
Re: Query.getResultList() returns null if the table does not existI 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
|
|
|
RE: Query.getResultList() returns null if the table does not existI was actually referring to "Effective Java" by Joshua Bloch. I'm not familiar with the Guy Steele reference, were you being sarcastic? :) Gili |
|
|
|
|
|
Re: Query.getResultList() returns null if the table does not existWhat 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@... >> https://dev.eclipse.org/mailman/listinfo/eclipselink-users >> >> >> > > eclipselink-users mailing list eclipselink-users@... https://dev.eclipse.org/mailman/listinfo/eclipselink-users |
|
|
Re: Query.getResultList() returns null if the table does not existConfirmed, this is fixed in trunk. Thank you!
Gili
|
| Free embeddable forum powered by Nabble | Forum Help |