Alias 3 « Map « JPA Q&A





2. Specifying a table alias to avoid column name colision    forum.hibernate.org

Greetings! I'm using the table-per-subclass mapping strategy using , and found that in one case, the parent and child table have a column with the same name. Here's what the database looks like: ParentDocument ------- id column1 ChildDocument ------ id parentId column2 I'm trying to get the child "id" field to use in a set mapping. Code:

3. Problem with different aliases in select and where clauses    forum.hibernate.org

Newbie Joined: Tue Jun 08, 2004 1:18 pm Posts: 1 Our code is usually building the following query: Code: /* criteria query */ select this_.ID as ID2_0_, this_.rateDate as rateDate2_0_, this_.ticker as ticker2_0_, this_.currency as currency2_0_, this_.rate as rate2_0_ from ...

4. How to control aliases in generated sql    forum.hibernate.org

5. Criteria with alias's    forum.hibernate.org

Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp Hibernate version: org.hibernate hibernate 3.2.5.ga org.hibernate hibernate-annotations 3.3.0.ga org.hibernate hibernate-entitymanager 3.3.1.ga Mapping documents: JPA Code between sessionFactory.openSession() and session.close(): Spring managed Full stack trace of any exception that occurs: NA Name and version of the database you are using: mySQL 5.05 The generated SQL (show_sql=true): ...

6. SQL Query results haywire when columns have same alias    forum.hibernate.org

SQLQuery query; query = session.createSQLQuery("select 1 as col, 2 as col"); List list; list = query.list(); Object[] row; row = (Object[]) list.get(0); // Column 1 should contain a number with integer value of 1 assertEquals(1, ((Number) row[0]).intValue()); // Column 2 should contain a number with integer value of 2 assertEquals(2, ((Number) row[1]).intValue());

7. adding alias to projection breaks the where clause    forum.hibernate.org

Hello, I'm observing that once a projection has an alias my where clause (restrictions) break the query: Would you please help me get passed this issue... here is how to produce it. Criteria c = ...CreateCriteria(demo.Cat.class); c.setProjection(Projections.projectionList() .add(Projections.groupProperty("color"))); c.add(Restrictions.eq("color", keyColor)); c.list() produces: select this_.color as y0_ from cats this_ where this_.color=? group by this_.color Now if I add an alias to ...

8. hibernate 2 to 3 migration: Exception could not locate alias    forum.hibernate.org

I am migrating hibernate 2 from hibernate 3.2. I am using Query.creareQuery( select distinct new com.heartbeat.profiler.commons.vo.DropdownIDValueBean(obj.id, obj.description, obj.deleteFlag) from InteractionType as obj left outer join obj.interactions as associationObject where ((obj.deleteFlag = 0) OR ((obj.deleteFlag = 2) AND (associationObject.id = 1196)))).setLockMode("obj", LOCKMODE.READ) With hibernate 2 it was working fine however for hibernate 3 it is giving me exception java.lang.IllegalArgumentException: could not locate ...

9. Giving alias name to a formula property.    forum.hibernate.org

Hi All, I defined a property with below query in formula ( select distinct hp.project_name from help_projects hp, help_comments hc where hp.project_id = this_.PROJECT_ID) and it is generating below query while running the application select this_.TICKET_ID as TICKET1_3_0_, ( select distinct hp.project_name from help_projects hp, help_comments hc where hp.project_id = this_.PROJECT_ID) as formula0_0_, from HELP_COMMENTS this_ where this_.priority=? and this_.status=? order ...





11. Group by alias or by subselect    forum.hibernate.org

Hello all, I have a special case where I would like to group by a subselect. Here is the code Code: public List findAverageScoreByMember(int maxResults) { log.debug("finding Contentrating instance by member"); try { String queryString = "select (select d.member from ...

12. Alias generation by Hibernate    forum.hibernate.org

13. Named SQL - result alias and class    forum.hibernate.org

New to named SQL, using Hibernate 3.2. I want to select one colum from TABLE_1 (e.g., COL_A), map it to attributeA of org.poc.MyObj.java and get the return type as org.poc.MyObj.java. When I invoke the named SQL from the client Java code, I get error as: [IBM][JDBC Driver] CLI0611E Invalid column name. SQLSTATE=S0022 I am using DB2 8.x. However, I can copy ...

14. Alias for an ORDER BY clause is not resolved    forum.hibernate.org

15. Alias for case..when..then..end not working    forum.hibernate.org

16. select 1 from .... HQL query gives undefined alias exception    forum.hibernate.org

Hi ALL , I get hibernate error undefined alias org.hibernate.QueryException: undefined alias: 1 Can any one tell me wats wrong in the HQL query? HQL QUERY : select distinct mct.num , mct.iss , mct.ch, mct.date , mpl.add , mct.jal, mct.ref, mpl.spons from DTO1 mpl, DTO2 maa, DTO3 mct where mct.add = maa.add and maa.add = mpl.add and mpl.spons = TT and ...





17. BUG IN HIBERNATE:alias for case..when..then..end NOT WORKING    forum.hibernate.org

Beginner Joined: Mon Jan 31, 2005 11:04 am Posts: 21 Hi, My goal is to make a polymorphic query (in HQL) and sort the results by type of class. The solution is to select through a "case..when.." the type (class) and order on this value. I want to give the "case..when..." an alias clazz to order on it but I get ...

18. How to give alias for nested queries    forum.hibernate.org

I am not able to find how to write this type of query in HQL select a.x, b.y from (select x,ab from tab1 where xxxxxx) as a and (select y.ab from tab2 where xxxxxx) as b where a.ab = b.ab; Can anyone let me know how to write it or any link to verify for it.

19. bug? @OrderBy does not add table alias in query    forum.hibernate.org

Newbie Joined: Mon Oct 13, 2008 9:17 am Posts: 1 Hibernate: 3.3.1.GA Java: JDK 1.5.0_14 SQL: MySQL 5.0.51a I'm trying to specify the order in which I want the values of a List to be returned on an Account by using the javax.persistence.OrderBy annotation, but I get an "ambiguous column '_name'" exception from hibernate when trying to use it An account ...

20. Second-level caching of HQL aliases    forum.hibernate.org

We're using second-level caching with Hibernate, and LEFT JOIN FETCHing multiple collections, via aliases in HQL: LEFT JOIN FETCH listing.secondaryTags tag LEFT JOIN FETCH tag.keyphrases LEFT JOIN FETCH tag.tagGroups In monitoring our cache, it appears that the main objects are being cached properly, but keyphrases and tag groups are not being cached. Is this a limitation with hql aliases?

21. Criteria and Alias    forum.hibernate.org

I guess you have one-to-many relation from SCHOOL to STUDENT_ORM table. If that is the case you might be declared a list in the School.java as follows: Even with your criteria query, session.createCriteria(School.class) .createAlias("Student_ORM", "Student") you can get the list of students. List studentList = school.getStudents(); If this not resolved your ...

22. auto-generated table alias in property formula    forum.hibernate.org

23. References to collections must be define a SQL alias    forum.hibernate.org

Login Register FAQ Search View unanswered posts | View active topics Board index Hibernate & Java Persistence Hibernate Users All times are UTC - 5 hours [ DST ] References to collections must be define a SQL alias Page 1 of 1 [ 1 post ] ...

24. Hibernate created different aliases in consecutive queries    forum.hibernate.org

Hi, I found out by setting show_sql = true, that in my app at least, hibernate will always parse consecutive hql queries from scratch, each time they are run. I assume that because each time, i see the same sql generated but with different aliases. Unfortunately, this means that the underlying rdbms cannot cache those queries and therefore we cannot benefit ...

25. Use of Criteria: Create Alias    forum.hibernate.org

Hello and thanks for your help in advance I'm using criteria and sometimes, to access to different levels of objects, i have to do the criteria.createAlias (path,alias) to join two objects and some other times, I have to set object1.object2 to be able to access to the data on the object 2. I thought it depended on if the second object ...

26. Adding restrictions to a disjunction with multiple aliases    forum.hibernate.org

DetachedCriteria criteria = DetachedCriteria.forClass(Breakdown.class) .createAlias("elevator", "el") .createAlias("ghostElevator", "ghost") .add(Restrictions.disjunction() .add(Restrictions.in("ghost.suggestedSociety.id", societies)) ...

27. Question on Caching-Strategies (alias usage)    forum.hibernate.org

Hello all, I have a question for my understanding regarding the concurrency strategies of the second level cache. In Java Persistence with Hibernate the description of the nonstrict-read-write cache says "Makes no guarantee of consistency between the cache and the database. If there is a possibility of concurrent access to the same entity, you should configure a sufficiently short expiry timeout. ...

28. org.hibernate.QueryException: undefined alias    forum.hibernate.org

Hi everyone, I have used Hibernate with BEA Weblogic 3.1 and I have not had any problems. Now I'm passing to BEA 4.0 and I'm starting to have some problems. Using the same war file, with BEA 4.0 I have the following Exception: org.hibernate.QueryException: undefined alias: TConfCodecPK [select TConfCodecPK.subtype FROM hibernate.classes.TConfCodec where confURI = 'sip:conf1239010359177@telecomitalia.it' and policy = 'allowed'] TConfCodec is ...

29. Base class alias used instead of subclass alias    forum.hibernate.org

Problem Definition We have defined a where clause on the tag in the parent class. B is a joined subclass of A. B has a one to one relationship to another class X. If you look at the "on " condition for B you will notice that its using b1_1_.ind='A' which is the parent's alias ...

30. hibernate undefined alias : 1 error    forum.hibernate.org

Hi, I am getting this error 'hibernate undefined alias : 1 error' when i write in hql .... and run the application private void handleOccupationSearchCategory(StringBuffer fromClause, StringBuffer whereClause, OccupationSearchCategory category) { if (category != null && category.isEnabled()) { logger.debug("Adding search criteria for occupation: " + category); // fromClause.append(" inner join js.cvoJsOccugroups jsg "); whereClause.append(" and js.id IN (").append( "select 1 from ...

31. problem with joined subtype and count (invalid alias)    forum.hibernate.org

HI all, I'm encountering a problem where I'm trying to get the numer of results a query will return (via count) but I'm not really managing to state this correctly in Hibernate. The class layout is as follows (I've tried to simplify it a bit to make the basic problem clear): There's a class BaseClass, it has the annotation Code: @Inheritance(strategy=JOINED) ...