column « Query « JPA Q&A





1. HQL querying columns in a set    stackoverflow.com

Is it possible to reach the individual columns of table2 using HQL with a configuration like this?

<hibernate-mapping>
  <class table="table1">
    <set name="table2" table="table2" lazy="true" cascade="all">
    ...

2. why is Hibernate selecting same columns twice?    stackoverflow.com

Hibernate: 
    /* load entities.Department */ select
        department0_.name as name4_0_,
        department0_.id as id4_0_ 
 ...

3. how to write a query in hibernate to select a column    stackoverflow.com

I'm using hibernate template to retrieve a data from the table course which has two columns, courseId and courseName. I want to select courseName from course using hibernate template. When I use, List courseNames=hibernateTemplate.find("courseName ...

4. Problem with processing count column with Hibernate    stackoverflow.com

I want to process the count column in my action how to do with help of hiberante.in my application every class is mapped to every table here I'm using billing ...

5. maintain the order of column when creating a new table using hibernate    stackoverflow.com

This is my pojo annotated as entity

@Entity
@Table(name = "book", catalog = "book_db")
public class Book {
    private Integer bookId;
    private String bookName;
    private ...

6. Hibernate criteria: how to order by two columns concatenated?    stackoverflow.com

I have a Person table which has two columns: first_name and last_name. The Person class has two corresponding fields: firstName and lastName. Now I'm using criteria api and trying to create ...

7. Hibernate Join Query Criteria and getting the Join Table with both the columns    stackoverflow.com

I have a table cartitems where the items added to the cart are stored in. It has columns: id (Primary Key), sku, quantity, userId, status, size and couple of other columns I also ...

8. JPA Order by with two columns    stackoverflow.com

I have two objects Objects: Objeto, Comunicado and ComunicadoTramite

@Entity
@Table(name = "objetos")
@Inheritance(strategy = InheritanceType.JOINED)
public class Objeto extends Fact {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name ...

9. How to order by agreggated columns in JPA/Hibernate?    stackoverflow.com

By executing this JPQL:

select o.key, count(o.id), sum(o.errors) from MyEntity o
group by o.key
Hibernate commits the following SQL:
select
    myentityn0_.key as col_0_0_,
    count(myentityn0_.id) as col_1_0_,
    ...





11. Hibernate Column in where clause is ambiguous    coderanch.com

Hi, I'm new to Hibernate. I'm working on a store app where I register ticket info (Ticket Object), ticket's purchased items (Item Object) and the user which made that purchase (User Object). I can store, read info, etc, no problem in mapping files, as far as I know, everything works ok... but I'm getting an error when I try to query ...

12. how to extract column names from hibernate query    coderanch.com

Here is my code: session.beginTransaction(); String caseQuery = " select " + "SUM(CASE WHEN H.ageGroup >=0 and H.ageGroup <=4 THEN H.monthlyHospitalizations ELSE 0 end) " + "as zto4, " + "SUM(CASE WHEN H.ageGroup >=5 and H.ageGroup <=14 THEN H.monthlyHospitalizations ELSE 0 end) as fivePlus, "+ "SUM(CASE WHEN H.ageGroup >=15 and H.ageGroup <=24 THEN H.monthlyHospitalizations ELSE 0 end) as fifteen, "+ "SUM(CASE ...

14. HQL and "IN" clause with multiple columns    forum.hibernate.org

15. Hibernate failed to create column using name 'order'    forum.hibernate.org

21-Feb-2010 9:00:05 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute SEVERE: Unsuccessful: create table Inscription (id bigint generated by default as identity (start with 1), order integer not null, position integer, competitionDiscipline_id bigint not null, mount_id bigint not null, rider_id bigint not null, primary key (id)) 21-Feb-2010 9:00:05 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute SEVERE: Unexpected token: ORDER in statement [create table Inscription (id bigint generated by default as ...

16. multile columns for count hql alternative    forum.hibernate.org

Hi, I am trying to write hql for the following sql: select (distinct item1, item2) from Test but get an error Caused by: org.hibernate.hql.ast.QuerySyntaxException: expecting CLOSE, found ',' near line 1, column 32 [select count(distinct o.item1, o.item2) from Test o where o.id = :el1] Elsewhere on this forum I saw that hql doesn't support multiple columns for count, is this still ...





17. Criteria to select columns from a table [Solved]    forum.hibernate.org

public List list() { return session.createCriteria(Message.class, "m") .setProjection(Projections.projectionList() .add( Projections.property("m.subject").as("subject") ) .add( Projections.property("m.message").as("message") ) ...

18. create-drop: how to control the column ordering?    forum.hibernate.org

Hello I'm experimenting around with JBoss DevStudio 3.0, Seam, etc. My DB is created on each full deploy, based on the Beans annotated with @Entity. My problem is the ordering of the columns within the created tables. First the column with annotation @Id is created, after that the ordering of the columns is alphabetically. This breaks my sql scripts import.sql (inserts ...

19. MappingException: Unable to find column with logical name    forum.hibernate.org

org.hibernate.MappingException: Unable to find column with logical name: state_code in ZipAreas org.hibernate.cfg.Ejb3JoinColumn.checkReferencedColumnsType(Ejb3JoinColumn.java:419) org.hibernate.cfg.BinderHelper.createSyntheticPropertyReference(BinderHelper.java:102) org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:88) org.hibernate.cfg.AnnotationConfiguration.processEndOfQueue(AnnotationConfiguration.java:456) org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:438) org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:309) org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1148) org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1226) org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:173) org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:854) org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:191) org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:253) ...

20. How do I store obtained columns from a query?    forum.hibernate.org

21. Hibernate Criteria and Count Column    forum.hibernate.org

22. Order by with two columns    forum.hibernate.org

Hi, I have two objects Objects: Objeto, Comunicado and ComunicadoTramite Code: @Entity @Table(name = "objetos") @Inheritance(strategy = InheritanceType.JOINED) public class Objeto extends Fact { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id_objeto", unique = true, nullable = false) private Integer id; @NotNull ...

24. Help with computed columns in SQL query    forum.hibernate.org

Hi, I am using Hibernate with SQL queries for the data retrieval. Now in one case I need to compute the result columns with SQL functions. The SQL statement looks like: SELECT distinct {obj}.DIOBJNR, CASE WHEN {obj}.DITOBJNR = 1 THEN 'X' ELSE '' END AS ATTR01, CASE WHEN {obj}.DITOBJNR = 5 THEN 'X' ELSE '' END AS ATTR02, CASE WHEN {obj}.DITOBJNR ...

25. Select specific columns    forum.hibernate.org

26. How to query two columns from two different tables    forum.hibernate.org

I'm currently evaluating Hibernate, so I'm quite new to this tool. Could some one tell me how to do simple query like this: select table1.attr1, table2.attr2 from table 1, table2 where ... this kind of query is commonly used when you want to construct UI display with two or multiple tables by join them together. I understand "join" is not a ...

27. "Unknown column 'false' in 'where clause'"    forum.hibernate.org

hi sir, i get a quite "Strange" exception, i would like to know how to due with it? i am running my application on MySQL 4.0.12 but it interpret my 'false' boolean value as a column name the sql statement look like this one String sql = "SELECT chu FROM hk.hku.csis.wsr.database.table.ConfigHasUUId as chu, " + "hk.hku.csis.wsr.database.table.UUIdMessageId as UUIdMessageId WHERE " + ...

28. query problem (Column not found)    forum.hibernate.org

Hi all, I'm going through the examples from the book "Java Open Source Programming with XDoclet, JUnit, WebWork, Hibernate". I get "net.sf.hibernate.JDBCException: Could not execute query" every time I'm trying to execute a query like List ret = session.find("from ContactInfo"); the code that executes is: public static void main(String[] args) throws Exception { Configuration config = new Configuration(); SessionFactory sf; Session ...

29. Could not execute query:invalide column!!?~    forum.hibernate.org

i dont know why ? when i use hibernate query other tables as "from Book as book " i can get the result, but when i use this table:goods include 54 columns, i can get nothing but errors list below. however when i change my sql as below, it do work. anybody can tell me why? queryString = new StringBuffer("select goods.pkid ...

32. The ordering of columns    forum.hibernate.org

Hibernate version:2.1 I have not been able to order the columns of my database tables the way I want. For example, in the mapping shown below I have mapped my attributes in the following order: S_ID, SUPER_S_ID, SUPER_S_LIST_INDEX, S_ALLOWED_T, SELECTED_T_ID In my database, however, I get the following order (note: S_ALLOWED_T is represented by a separate table): S_ID, SUPER_S_ID, SELECTED_T_ID, SUPER_S_LIST_INDEX ...

33. HQL --> SQL failing to translate WHERE column and ORDER    forum.hibernate.org

Hibernate is chugging along well for my other tables but something about this simple query is stuffing it in the translation from HQL to SQL. A particular column in SQL called family_name iis mapped to familyName. When I execute a HQL query as such: from au.com.iman.claims.common.ClaimsPayment where familyName >= '' order by familyName The SQL generated is: select claimspaym0_.id as id, ...

34. Select ... more than one column having same name    forum.hibernate.org

Hibernate version: 2.1.6 Mapping documents: (Simplified for ease of posting): Code between sessionFactory.openSession() and session.close(): Just trying to do ...

35. Selecting a couple of columns    forum.hibernate.org

36. Ordering a COUNT() column    forum.hibernate.org

I can't seem to get this to work. ClubMember has a many-to-one link back to Club. Code: select members.club, count(members.id) memTotal from ClubMember members group by members.club order by memTotal Produces the following error using Eclipse Hibernate Console with 3.0.2: Code: org.hibernate.QueryException: , expected in SELECT [select members.club, count(members.id) memTotal from p2p.common.clubs.ClubMember members group by members.club order by memTotal ] ...

37. Order by an aggregated column    forum.hibernate.org

38. Criteria to select only special columns    forum.hibernate.org

Hi, is it possible to use the criteria API in that way, that only special columns of a table are selected? If I use the criteria API every column which is mapping in the .hbm.xml file will be selected by the generated SQL. But sometimes it is useful to select only special columns. Perhaps if I need only 3 columns in ...

39. Multi column IN clause    forum.hibernate.org

40. many-to-one multicolumn join/select with multiple columns    forum.hibernate.org

... AssociatedTypeID ...

41. no column name found for in select disti    forum.hibernate.org

42. Hibernate selects all columns in all tables in FROM clause    forum.hibernate.org

Hi, I am using Hibernate 3.1. I got a criteria query that joins multiple tables. When I execute the query, the SQL generated has all columns from all tables in FROM clause. Is there a way, I can restrict hibernate to select cloumns from main criteria only? Below is the example. Criteria query: criteria = getSession().createCriteria(JournalLine.class); criteria.createAlias("journal", "jou").createAlias("jou.journalType", "jty").add(Restrictions.ne("jty.txnNature", JournalType.TxnNature.CASH)); criteria.list(); ...

43. How to select single column...    forum.hibernate.org

44. ORDER BY column in related object    forum.hibernate.org

Hibernate version: 3.1.2 Pseudo Mapping documents: Code: ... other properties ... ...

45. order by columns of two tables    forum.hibernate.org

46. Criteria and too many columns in final Select    forum.hibernate.org

select this_.id as id0_1_, this_.name as name0_1_, this_.b_id as b5_0_1_, b1_.id as id2_0_, b1_.name as name2_0_ from A this_ inner join B b1_ on this_.b_id = b1_.id where ...

47. How do i get Column Names from the Query Object ?    forum.hibernate.org

Query q = createQuery("from Ordermaster"); I want to get the following information from the result: 1). Column Names 2). Column Count I tried giving alias in the query - q = "select om.OrderId as OrderNo from OrderMaster" and then used q.getReturnAliases(); Its working but if there is some easy way out, please help. This way shall be too cumbersome. Please help. ...

48. Order by joined table column    forum.hibernate.org

I hope this is a simple one. I have two classes, Button and Category. A Button has a nullable Category property. That is, a Button can belong to a single Category, or it can be "uncategorized". Both the Button and Category classes have a displayOrder property. I want to pull a list of Buttons, ordered first by the Category's displayOrder property, ...

49. MappingException: Unable to find column with logical name    forum.hibernate.org

Hibernate version: 3.2 Name and version of the database you are using: postres 8.1 Hi, I'm trying to apply composite-id to inheritance hierarchy. This is my situation: EMBEDDED-ID: public class NewId implements Serializable { protected Long id1; protected Long id2; public NewId() { } @Column(nullable = false, unique = false) public Long getId1() { return this.id1; } public void setId(Long id1) ...

50. Operations on columns using Criteria queries    forum.hibernate.org

Hibernate version: 3.2.2 Name and version of the database you are using: Oracle 10g Hi all, Just wondering if this is feasible using Criteria queries, and how... Let's say I want to fetch the rows of a table consisting of 2 DATE columns (DATE1 and DATE2) in which DATE1 and DATE2 are from the same month and year. The only solution ...

51. How to get column names from hibernate query?    forum.hibernate.org

wut? ... Hibernate doesn't work like that. Column names are mapped to fields to a domain/data/pojo object. Which you will have for each table... Then you use HQL not SQL to query for actual objects as opposed to raw data from the DB. Try reading up on some hibernate basics. From what you posted it doesn't sound like you are using ...

53. Selecting some columns into a hash    forum.hibernate.org

Hi, how can I get the results of a query and insert in a hash or list or any other list object example: Query q = Sistema.getSession().createQuery("select distinct new Guia(g.guia, b.nome) from Guia g, Beneficiario b, GuiaEvento e where g=e.guia and e.dataexecucao between :di and :df and b=g.beneficiario and b.empresa=:empresa"); q.setEntity("empresa", this); q.setDate("di", dataInicial); q.setDate("df", dataFinal); return q.list(); My Guia object ...

54. (sql-query) 3.2.cr3: invalid column name. 3.2.cr2: works ok!    forum.hibernate.org

Hibernate version: Test case works OK with hibernate-3.2.0.cr2 Same test case doesn't works with hibernate-3.2.0.cr3 Mapping documents:

55. Cannot find the a Table Column using Criteria    forum.hibernate.org

Author Message shardul.bhatt Post subject: Cannot find the a Table Column using Criteria Posted: Mon Sep 17, 2007 8:38 am Beginner Joined: Fri Sep 08, 2006 7:29 am Posts: 35 Hibernate version: Hibernate 3.0 Mapping documents: CXI_CON_EXTENDED_INFO Code: