persistence icon indicating copy to clipboard operation
persistence copied to clipboard

return type of createNativeQuery(String, Class)

Open lukasj opened this issue 12 years ago • 9 comments

Hi,

I've got a minor suggestion:

EntityManager.createNativeQuery(String, Class)

could return a TypedQuery as the result class is specified:

TypedQuery<T> createNativeQuery(java.lang.String sqlString, java.lang.Class<T> resultClass)

-Adrian

lukasj avatar Mar 20 '13 11:03 lukasj

  • Issue Imported From: https://github.com/javaee/jpa-spec/issues/52
  • Original Issue Raised By:@glassfishrobot
  • Original Issue Assigned To: @ldemichiel

lukasj avatar Aug 31 '18 16:08 lukasj

@glassfishrobot Commented Reported by agoerler

lukasj avatar Mar 20 '13 11:03 lukasj

@glassfishrobot Commented edvin said: Is there a more complex underlying reason for this not being fixed? At first glance it seems trivial.

lukasj avatar May 05 '14 08:05 lukasj

@glassfishrobot Commented hirdil said: It would be nice to have this feature.

lukasj avatar Nov 28 '16 16:11 lukasj

@glassfishrobot Commented neilstockton said: You mean, apart from the fact that there already is a method createNativeQuery(String sqlString, Class resultClass)

returning Query. So for backwards compatibility you can't just change the signature. Unless backwards compatibility is thrown away of course ...

lukasj avatar Nov 29 '16 09:11 lukasj

@glassfishrobot Commented This issue was imported from java.net JIRA JPA_SPEC-52

lukasj avatar May 05 '17 06:05 lukasj

I don't think this is possible without breaking backwards compatibility and this seems very minor. I suggest just closing it to reduce clutter.

Reza Rahman Jakarta EE Ambassador, Author, Blogger, Speaker

Please note views expressed here are my own as an individual community member and do not reflect the views of my employer.

m-reza-rahman avatar Apr 27 '21 03:04 m-reza-rahman

I think we should not do anything about this issue for now, but I do think it's something we should circle back to later, probably at the same time we look at #9.

Changing the return type of the method from Query to its subtype TypedQuery is a breaking change, but it's the most innocuous sort of breaking change, and it's mostly source-compatible. So I think it's the sort of change we could quite safely make in the next major version (i.e. 4.0).

On the other hand, depending on how we do #9, it's remotely possible that this change won't be necessary after all.

gavinking avatar Aug 15 '23 16:08 gavinking

I support this for being included in 4 as well. In the meantime, will continue using https://docs.flowlogix.com/#section-nativequery for this functionality

lprimak avatar Aug 28 '23 20:08 lprimak