named-query

NamedQuery: IllegalArgumentException (Query not found) after externalizing entities

岁酱吖の 提交于 2019-12-21 03:42:17
问题 I have successfully used javax.persistence.NamedQuery in combination with JPA2. The named queries are defined at the top of the entity class files, and are used from Stateless EJBs (entity facade). Now I had to extract the entity class files into a separate Jar file (so we can use them from a Google Web Toolkit project). Obviously I still incude the jar, but now the facade bean does not find the query anymore: java.lang.IllegalArgumentException: NamedQuery of name: Store.findByExternalId not

NHibernate - How to log Named Parameterised Query with parameter values?

孤街醉人 提交于 2019-12-20 04:38:16
问题 I have a parameterised named Query like this : Query moveOutQuery = session.createSQLQuery(moveOutQueryStr.toString()) .addEntity(MyClass.class) .setParameter("assignmentStatus", Constants.CHECKED_OUT) I want to see the actual SQL query with parameters filled in. However while debugging I only get the following query: Select * from my_assignment WHERE assignment_status in ( :assignmentStatus ) Why isn't the assignmentStatus being substituted for its real value? 回答1: You may log each SQL to

Jpa namedquery with left join fetch

ぃ、小莉子 提交于 2019-12-19 07:59:56
问题 this is my namedquery: @NamedQuery( name = "User.findOneWithLists", query = "SELECT u FROM User u " + "LEFT JOIN FETCH u.aTemplates " + "LEFT JOIN FETCH u.bTemplates " + "LEFT JOIN FETCH u.bp " + "LEFT JOIN FETCH u.aCredentials " + "LEFT JOIN FETCH u.st WHERE (st.deleted = false) " + "LEFT JOIN FETCH u.bCredentials " + "LEFT JOIN FETCH u.cl " + "WHERE u.id= :id") My problem is that I get an error when the application starting: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected

Jpa namedquery with left join fetch

流过昼夜 提交于 2019-12-19 07:59:29
问题 this is my namedquery: @NamedQuery( name = "User.findOneWithLists", query = "SELECT u FROM User u " + "LEFT JOIN FETCH u.aTemplates " + "LEFT JOIN FETCH u.bTemplates " + "LEFT JOIN FETCH u.bp " + "LEFT JOIN FETCH u.aCredentials " + "LEFT JOIN FETCH u.st WHERE (st.deleted = false) " + "LEFT JOIN FETCH u.bCredentials " + "LEFT JOIN FETCH u.cl " + "WHERE u.id= :id") My problem is that I get an error when the application starting: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected

Hibernate: Mapping custom column names in stored procedure named query

纵然是瞬间 提交于 2019-12-18 09:04:19
问题 I currently have the following named query that wraps around a stored procedure:- <hibernate-mapping> <sql-query name="mySp"> <return-scalar column="name_first" type="string" /> <return-scalar column="name_last" type="string" /> { call some_sp :param } </sql-query> </hibernate-mapping> The columns name_first and name_last are the exact column names returned by the stored procedure. I created a bean that contains the same column names so that I can map the queried result into that bean. public

JPQL IN clause: Java-Arrays (or Lists, Sets…)?

独自空忆成欢 提交于 2019-12-17 04:43:09
问题 I would like to load all objects that have a textual tag set to any of a small but arbitrary number of values from our database. The logical way to go about this in SQL would be to build an "IN" clause. JPQL allows for IN, but it seems to require me to specify every single parameter to IN directly (as in, "in (:in1, :in2, :in3)"). Is there some way to specify an array, or a list (or some other container) that should be unrolled to the values of an IN clause? 回答1: I'm not sure for JPA 1.0 but

h2 Database performance issues with Named Query

三世轮回 提交于 2019-12-14 03:55:59
问题 Just some pre-information. We are using a H2 File Database which is already around 15 GB. Our Application runs on Windows Clients Jetty Webserver H2 File Database Every time Data needs to be updated on client side, the user will get a zip File with XML-Files. Either an XML file will be imported to the DB or the xml file has a flag "delete" and the entry in the DB will be deleted. Every import of a zip file has a data version. The import is done manually with Java. XML Files are deserialized

How to map a sql function as named query with Nhibernate's loquacious mapping?

心已入冬 提交于 2019-12-13 19:12:26
问题 I have replaced all my NHibernate xml mapping files by loquacious mappings (mapping by code). The only thing I can't figure out is if it is possible to define this named query using loquacious mappings: <?xml version="1.0" encoding="utf-8"?> <hibernate-mapping namespace="Domain" assembly="Domain" xmlns="urn:nhibernate-mapping-2.2"> <sql-query name="MyFunction"> <query-param name="Inputparam1" type="Int32"/> <query-param name="Inputparam2" type="Int32"/> <return-scalar column="ResultParam"

Difference between @NamedQuery and @NamedNativeQuery in JPA-EclipseLink

你离开我真会死。 提交于 2019-12-13 05:15:21
问题 Hi I am a newbie using persistence API, and have also read few posts related to the same and got a very few understanding between these two. the below post really helped me clear my concepts for @NamedQuery What is a named query? I now wanted to learn all the important key differences between NamedQuery and NamedNativeQuery, and which one is preferred most while dealing with JPA-QL, and performance wise. Thanks! 回答1: A native query isn't JPQL. A regular query is converted by the persistence

How can I test a boolean parameter in a NamedQuery with JPA?

一个人想着一个人 提交于 2019-12-13 03:17:54
问题 How can I tell JPA (EclipseLink 2.4) to check a boolean IN parameter whether it is true or false? SELECT e FROM MyEntity e WHERE :inParam = TRUE AND e.x = 'bla' or SELECT e FROM MyEntity e WHERE :inParam = true AND e.x = 'bla' Doing it as above results in an exception that TRUE wouldn't be a valid value for inParam . 来源: https://stackoverflow.com/questions/29033065/how-can-i-test-a-boolean-parameter-in-a-namedquery-with-jpa