database « Query « JPA Q&A





1. Why NHibernate simple select in HQL to SQLite database is not working?    stackoverflow.com

I've recently started using FluenNHibernate and some weird problem appeared when I tried to write unit test with SQLite. I use SQLite in memory database for test, for each test method I ...

2. Selecting MappedSuperclass from the database (Hibernate)    stackoverflow.com

Problem

I have a @MappedSuperclass called Data as the parent of every Entity in my database. It contains common attributes like Id etc. I then have an entity that extends Data which ...

3. Hibernate... how does one do database/SQL queries?    stackoverflow.com

I (think I) understand that Hibernate offers me access to a relational database essentially as if I had a class(es) that matched whatever view(s) I define of some tables. How do I ...

4. Force Hibernate query to access database    stackoverflow.com

I have loaded an entity into my transaction and have changed a property of that entity. The transaction is not yet commited. Now I would like to get the original value ...

5. JPA and order of columns in the database    stackoverflow.com

I'm using Eclipselink as my persistence provider. Is there any way to specify the order in which the columns appear in the database? The column-order in the database doesn't match the ...

6. ORM querying with transitive dependency    stackoverflow.com

Here's is a part of my database schema: enter image description here So I'm using the tables pages,points and items to generate the layout of my page. To each item is ...

7. In hibernate how to use not in clause    stackoverflow.com

i am having two table jobs and production production table has jobid field which refers jobid of jobs table. In hibernate how to use not in clause to achieve following sql query SELECT * FROM ...

8. Java EE named query join    stackoverflow.com

I have two entities

   @Entity    
    public class Tabulka{

@OneToMany(mappedBy = "tabulka")
    private List<VysledkyHraca> vysledkyHraca;
.
.
.

}
and
    @Entity
   ...

9. Free-form queries to the database over HTTP    stackoverflow.com

I am working on providing a REST interface to some database tables. I want to provide the client a way to fetch data in a dynamic fashion. e.g. /customer/1234?active=true&gender=M&wealth>100000&... So the idea is to have ...





10. Hibernate help me write query    stackoverflow.com

Im making an email client in java. When user creates mail with attachment(document), it saves all the data about email message in database but in multiple tables, like attachement title in ...

11. problem - database select with hibernate    coderanch.com

Hi, Env: Spring,Hibernate, SQLServer I am trying to fetch the records from "Image" table. My query is pretty simple: public List getAll() { return getHibernateTemplate().find("from Image"); } But the query that hibernate generates is: select image0_.UID as UID0_ from Image image0_ Exception trace: SEVERE: Invalid object name 'Image'. Exception in thread "main" org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is org.hibernate.exception.SQLGrammarException: ...

12. how can i make sql queries database independent using Hibernate?    coderanch.com

Which part are you worried about not being database independent? Hibernate abstracts out the database thought the hibernate.cfg.xml file. So, you code Hibernate once, and you just change the entries in the xml file when you switch databases. Hibernate uses HQL, Hibernate Query Language, as opposed to SQL, so even there, you are buffered against a specific database SQL call. >>for ...

15. Database Query using Hibernate    coderanch.com

Hi, We are working on a migration project. Currently we are using stored procedures for fetching the data which uses linked servers to fetch cross server data. Below is a query to give you some idea. Select C.CompanyName, WHName = case when PO.DelWhID = 0 then 'Multiple' else (select WarehouseName from Server2.Configuration.dbo.Warehouse where WarehouseID = PO.DelWhID) end, IV.CreateDate, IV.ShipDate, PO.PONumber From ...

16. Cross database query using hibernate    coderanch.com

Currently we have 2 databases on our system where we are using linked servers (SQL SERVER) to fetch the data from both the servers (Cross database query). In future we would like to move our Database from SQL Server to MySQL and thus we does not won't to use native sql or stored procedures as it will add extra efforts for ...





17. Hibernate - connect to database and run query.    java-forums.org

Sorry for lame question, but I`ve got a problem - can`t connect to MySQL dbs via hibernate with set up plugins in NetBeans IDE. I had created 2 files hibernate.cfg.xml and hibernate.hbm.xml then imported hibernate packeges and class compiled with error: May 22, 2011 9:04:03 AM org.hibernate.cfg.Environment INFO: Hibernate 3.2.5 May 22, 2011 9:04:03 AM org.hibernate.cfg.Environment INFO: hibernate.properties not ...

18. Database Query using Hibernate    java-forums.org

Hi, we are working on a migration project. Currently we are using stored procedures for fetching the data which uses linked servers to fetch cross server data. Below is a query to give you some idea. Select C.CompanyName, WHName = case when PO.DelWhID = 0 then 'Multiple' else (select WarehouseName from Server2.Configuration.dbo.Warehouse where WarehouseID = PO.DelWhID) end, IV.CreateDate, IV.ShipDate, PO.PONumber From ...

19. Problem with using getCurrentSession() to query database    forum.hibernate.org

Generally, the usage of opensession() is not recommended since it opens a new session that needs manual closure since this comes away from spring or container managed sessions. However opencurrentsession() asks the container to get the session that is already open and is the current session in use. Using this is highly recommended! But can you let me know the query ...

20. Columns order in database    forum.hibernate.org

Hi, I'm currently using the xml mapping files to create the tables on the database, however I found a problem that I would like to specify the order the fields columns are created in my database and I dont find a way... I'lll post an example: this is my mapping file:

21. Database query with calculation    forum.hibernate.org

Hi, hoping somebody can point me in the right direction with a problem I'm having. I need to retrieve a list of locations based on their vicinity to a given Place. So for example, I have "Place" and "Attraction" as mapped entities, both of which have a lat/lng. So in SQL I could do something like: Code: select a.*, SQRT(POWER((69.1 * ...

22. Order of database access operations performed by Hibernate    forum.hibernate.org

Hello, as far as I know, when using Hibernate, data base accesses (SQL queries) are executed when arriving at the end of the Transaction code (in the Java source code). This corresponds to what I have observed when debugging. Currently, in the Java code, I am deleting something from the database, then adding another object (actually to replace the former by ...

23. Query takes very long on different databases with same setup    forum.hibernate.org

Hello everybody, I use hibernate 3.3.2 on a MSSQL server and I encounter problems while executing a select statement on the same host to different databases. While it works fine for the first database (<5) it takes more than 10 minutes on the other one. During debugging sessions I noticed that hibernate takes all the time at the preparing statement task. ...

24. Database Query using Hibernate    forum.hibernate.org

Hi, we are working on a migration project. Currently we are using stored procedures for fetching the data which uses linked servers to fetch cross server data. Below is a query to give you some idea. Code: Select C.CompanyName, WHName = case when PO.DelWhID = 0 then 'Multiple' else (select WarehouseName from ...

25. Query problems with a Database view    forum.hibernate.org

Beginner Joined: Wed Oct 01, 2003 3:35 pm Posts: 33 I have the following mapping file for a database view under MS SQL 2000:

26. Multiple Databases in a single query    forum.hibernate.org

Ok.. so I'm happy that hibernate will be fine in my multi-database environment.. I can just provide my own connection. However What if... (and please don't talk to me about this design.. it's not my doing) What if we have (lets make it simple) two databases and a table in database 2 has a foreign key to a table in database ...

27. Name of the database column in HQL query?    forum.hibernate.org

public class Evenement implements Serializable{ private Long id; private String initiateur; public Evenement() {} public Long getId() { return id; } public void setId(Long id) ...

28. Cross database query    forum.hibernate.org

Just wondering if there is an easier way to do the following... Each application has a different database, but each application also shares a core database. This core database has User access information/permissions, etc. When performing a query it would be nice if I could do a join with the user_id from the application database and the core database to get, ...

29. Find out if the underlying DB supports scrollability    forum.hibernate.org

How can I find out thru' Hibernate if the underlying Data base ( JDBC driver ) supports scrollability or not. There is a ScrollMode class which has a public method lessThan. But how do I find thru' Hibernate API what the current scroll mode is or what is supported by the underlying JDBC driver? Before invoking the scroll method on the ...

30. 'order by' does not work with postgres db    forum.hibernate.org

Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp [b]Hibernate version:3.0[/b] [b]Mapping documents:[/b] [b]Code between sessionFactory.openSession() and session.close():[/b] [b]Full stack trace of any exception that occurs:[/b] [b]Name and version of the database you are using:postgresql 8.0[/b] [b]The generated SQL (show_sql=true):[/b] [b]Debug level Hibernate log excerpt:[/b] Hi, am using hibernate with postgresql database. When I do a simple query such as ...

31. Accessing two different databases in one query    forum.hibernate.org

32. DB changes not seen by hibernate query    forum.hibernate.org

In my application, I have Folders that contain Documents. Recently, I switched from doing folder.getDocuments() plus hand coded filtering to a complex HQL query: Code: private static final String ADMIN_QUERY = "from Document d join d.folders f join d.latestVersion v left join d.docType dt " + ...

35. select across multiple db    forum.hibernate.org

36. querying the database    forum.hibernate.org

I am trying to query an oracle database that contains 3 tables, Company, Employee, and Product. Company companyId PK locationId PK other fields Employee ssn PK companyId PK, FK locationId PK, FK other fields Product productId PK companyId PK, FK locationId PK, FK My mapping for the company class is:

37. Hibernate ORDER BY behaves differently than database!! HELP!    forum.hibernate.org

When I execute below query in SQL Query analyzer, the resultset order that I get are different than when I run it thro Hibernate. Below is the SQL defined in mapping file. SELECT InsuredEntityAddl.InsuredEntity_UID, InsuredEntityAddl.Ins_Ent_Ver_NBR, InsuredEntityAddl.InterestType_CDE, InsuredEntityAddl.InterestSeq_UID, InsuredEntityAddl.InsName_Type_CDE, InsuredEntityAddl.InsName_Seq_UID, InsuredEntityAddl.Insured_Other_NME, InsuredEntityAddl.Policy_NBR, InsuredEntityAddl.Certificate_NBR, InsuredEntityAddl.Policy_Version_NBR FROM InsuredEntityAddl INNER JOIN PolicyChange on InsuredEntityAddl.Policy_NBR = PolicyChange.Policy_NBR and InsuredEntityAddl.Certificate_NBR = PolicyChange.Certificate_NBR and InsuredEntityAddl.Policy_Version_NBR = ...

38. Criteria queries and database indices    forum.hibernate.org

Hi, I am using hibernate to query a database of orders. The result set returned is generally in the thousands. We have created indices on the database for the searches. The problem is that while using the crtieria class, expressions or restrictions get added in a certain order. If a certain criteria is not applicable, we would have to skip it ...

39. encountered SQLException [Database not selected yet.]    forum.hibernate.org

Full stack trace of any exception that occurs:2006-05-31 12:03:02,336 ExecuteThread: '13' for queue: 'weblogic.kernel.Default' ERROR pers.global - RuntimeException org.springframework.jdbc.UncategorizedSQLException: (HibernateAccessor): encountered SQLException [Database not selected yet.]; nested exception is java.sql.SQLException: Database not selected yet. java.sql.SQLException: Database not selected yet. at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java(Inlined Compiled Code)) at com.informix.jdbc.IfxSqli.addException(IfxSqli.java(Compiled Code)) at com.informix.jdbc.IfxSqli.receiveError(IfxSqli.java(Compiled Code)) at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java(Compiled Code)) at com.informix.jdbc.IfxSqli.receiveMessage(IfxSqli.java(Compiled Code)) at com.informix.jdbc.IfxSqli.executePrepare(IfxSqli.java(Compiled Code)) at com.informix.jdbc.IfxResultSet.executePrepare(IfxResultSet.java(Inlined Compiled ...

41. Query across databases    forum.hibernate.org

Hi all! I already tried to get a solution to my problem in the German forum a few days ago, but unfortunately there haven't been any replies yet. I hope there is a solution, so I'll try here again: I have to make a query across several databases. At the moment, the concept looks thus: DB1 contains meta-information, i. e. it ...

42. Need to hit database for each query    forum.hibernate.org

Hibernate version: 3.2 BEA WebLogic: 8.15 Just a simple query, and yes I have tried all possible solutions. I simply want to make sure that Hibernate does not load/persist data in cache, rather it should hit the database everytime. This is what I have done so far: 1) Hibernate configuration: org.hibernate.hql.classic.ClassicQueryTranslatorFactory false false ...

43. What query should I use for a linked list database table?    forum.hibernate.org

I am interested in using Hibernate to query a table that is a Linked List. One row in my database represents a client. This client can have a parent client and so on. The Linked List relationship is a one to many. One parent can have many children, but one child can have only one parent. The parent may be null. ...

45. selecting from multiple DB    forum.hibernate.org

Hi, you know if is it possible to make a query referencing multiple DB in HQL? That is: I have three legacy system, each one with its DB (one oracle, one sqlserver, one mysql ...don't tell...), I already have all them in one application using different hibernate configuration files. I want to make a query like select table_from_db_a from Table_from_db_a table_from_db_a ...

47. Can/Should I 2nd-level-cache/query-cache all my database?    forum.hibernate.org

Hello, I have a web application that runs for a period of 2 months. In the first week users register themselves. After that, there are very minor changes in the database. At week 6, about 5 entities are heavily changed. I have about 70 entities in my system. Should I cache them all (or almost all)? My whole database uses 40MB ...

48. can we use two database in single query    forum.hibernate.org

Shards is usefull if you 're looking for horizontal partitioning (for example a Person record is in a different database dependend on where he lives). That doesn't sound like your use case. As far as I know, an entitymanager is for only 1 datasource (so 1 database), so you can't do that directly. You can use different entitymanagers, but you 'll ...

49. Simple Database query always empty (newbie)    forum.hibernate.org

Newbie Joined: Tue May 20, 2008 1:09 pm Posts: 5 Hello, I'm developing an application using Seam, which integrates Hibernate. I've created an Entity Bean named EmailGather, which holds a simple string (email address) and a boolean. I have a JSF/Seam xhtml page that gathers the info from the user, and puts it into the database. This works great, so I ...

50. Query needed to join Multiple database tables    forum.hibernate.org

I have an requirement getProfileIdBySkills(Map skills) Here SkillsInformation is the persistent class.Here languages,servers,technologies,tools,frameworks are of sets type in SkillsInformation class. In each set , i have skills_info_id,skills_name are there. I have to collect each skills_name from each set type and finally i hav to collect all skills_name in a map. And pass that map of skills_name as a parameter to above ...

51. SQL Query is not getting to the database.    forum.hibernate.org

Hi, When I make a query with below code it's supposed to return a list of Transfer objects. It works well when I first invoke the call it returns the up to date records from the database however it always returns the very same result of the first call afterward. I'm new to hibernate so your help will be appreciated . ...

52. database Query pasing for HQL Queries    forum.hibernate.org

53. how can i find the po object by the pure db column name    forum.hibernate.org

Hi,guys,i encounter a problem with hibernate .I have two po : RecruitCollegeMajor implements BaseBean { private Integer collegeMajorId; private BaseCollege baseCollege;//a foreigner key(in the db table is collegeid) . . . } BaseCollege implements BaseBean{ private Integer collegeId private String collegeNum; . . . } if i know the column collegeId of the database table RecruitCollegeMajor ,how can i know the ...

54. How to count every database call    forum.hibernate.org

Hello each and everyone, In order to count all database calls do you by any chance know a better way than wrapping the jdbc driver ? Basically I need the measure the number of queries and time spent in the database tier (I have Spring 2.5 and Hibernate 3.3). Any help is quite much appreciated... Thanks

55. Multiple DB providers and DB selection    forum.hibernate.org

Good afternoon, I have an application with a login page that allows you to select the DB you wish to connect to via a drop-down list. What is the best way to accomplish this without imposing a fair amount of overhead for the other db providers that are not actually used during the lifecycle of the application (one and only one ...

56. Could not Query DB. could not initialize a collection    forum.hibernate.org

Author Message jl061403 Post subject: Could not Query DB. could not initialize a collection Posted: Thu Aug 27, 2009 3:09 pm Newbie Joined: Wed Nov 12, 2008 12:16 pm Posts: 15 I cannot figure out what i am doing wrong here - but for some reason i can't initialize my collection and my table can't be found. Any help ...

57. Customising Queries for a very simple DB    forum.hibernate.org

Hi there, this is my first post ever in the forum. Nice to meet you all. How do I change the Queries created by the SchemaGenerator class? I got a really simple JDBC Driver ( don't even support the NOT NULL statement) that can't parse the regular queries. I want to use the hbm2dll feature of Hibernate but it need to ...

58. hibernate query...how to connect two databases...    forums.oracle.com

public void setId(int id) { this.id = id; } public int getId() { return id; } public void setAccount(String account) { this.account = account; } public void setPassword(String password) { this.password = password; } public void setBalance(String balance) { this.balance = balance; } public String getAccount() { return account; } public String getBalance() { return balance; } public String getPassword() { ...