SQL « Map « JPA Q&A





1. JPA - map entity to sql query?    stackoverflow.com

I'm writing a JPA connector to a legacy sistem. The problem is, DB design in the system is.. well.. horrible. I need to implement an entity that maps to three tables. I ...

2. Hibernate - New colums from a joined table    stackoverflow.com

I have a class User object. I am trying to load this object from the Database using Hibernate. My SQL statement is:

SELECT
 users.uid          ...

3. Hibernate computed property and SQL-Queries    stackoverflow.com

I've implemented a computed property to my configuration which works fine if I'm using HQL only. Sadly there are places where SQL-Queries are executed which I can't build into HQL. Am ...

4. Hibernate Criteria - Return parent records that have child records    stackoverflow.com

All, I'm probably over-analyzing this problem, but... Given table "A" with two one-to-many relationships "A1" and "A2", return all records in table "A" that have at least one child record in either table ...

5. mybatis, the world's most popular sql mapping framework?    stackoverflow.com

mybatis' homepage has this quote

mybatis, the world's most popular sql mapping framework
There are only 16 questions on StackOverflow about mybatis, compared to 5,299 on hibernate. Look at Google trends. ...

6. Many to Many Mapping in Hibernate without Collection    stackoverflow.com

Given a classic example of Student and Subject where they have a many-to-many relationship, is there any way to map them using POJOs w/o the use of Collections? e.g. Student.java

@Entity
class Student{
  @id
  int ...

7. Hibernate one to one mapping using only foreign id    stackoverflow.com

Given we have

tables Person (id, address_id) and Address (id, town)
and POJO
class Person {
 int id;
 int addressId;  
} ...

8. hibernate - many-to-one using addJoin    stackoverflow.com

I have a many-to-one relationship, where a MessageContents object has a set of Messages, and each Message has a foreign key to a MessageContents. I have the following query:

String sqlQuery = "SELECT ...





10. plz provide complete example of hibernate mapping one to many with SQL tables    coderanch.com

Shreya, please do not create two seperate accounts and then post as though you are two different people. Your other post here. http://www.coderanch.com/t/217326/ORM/java/plz-provide-Complete-example-Hibernate Is under a different name, and you are asking a very big open ended question, which is what an internet troll would do, so I am closing these two threads. If you really need help, please first do ...

11. Hibernate mapping sql char to java char    coderanch.com

12. class property and sql-query return-property strict mapping?    forum.hibernate.org

Hi buddies, I am a beginner in hibernate field, now I am doing a project which uses hibernate to call procedures, now It works, but an issue is not fixed. I have a module called Opportunity which has more than sixty columns, so in opportunity.hbm.xml, tag includs all the properties, but for some searching, we only need several columns, so ...

13. How to map results of a SQL query    forum.hibernate.org

Regular Joined: Tue Oct 10, 2006 2:21 pm Posts: 58 I wish to execute a query containing an outer join of two not-really-related tables. By "not-really-related" I mean that there is a many-to-many relationship between two tables in which there may or may not be a coincidental match between two columns. (A user may match 0-to-many Speed Dial names to a ...

14. How to map java Enumerations to a SQL column?    forum.hibernate.org

15. sql-query in the mapping file    forum.hibernate.org

16. Inheritance in SQL query    forum.hibernate.org

Hi, I am running Hibernate 2.1.1 and Oracle 9.2 for my web application. I have two classes one inherited from the other class Person:- Code: /** @hibernate.class */ public class Person { private Integer personId private String loginName; ... /** @hibernate.id generator-class="native" */ public Integer getPersonId() { ...





17. Mapping for SQL SET type?    forum.hibernate.org

Does Hibernate offer any convenient mapping for the SQL SET type? From the MySQL manual: A SET is a string object that can have zero or more values, each of which must be chosen from a list of allowed values specified when the table is created. I am thinking about Hibernate mapping an SQL SET to maybe a java.util.Set or an ...

18. How to map SQL datetime to persistent class?    forum.hibernate.org

Hi all, I am facing a problem in getting the time value from the persistent class. In DB the type is datetime (8) and I have mapped that column to a property of type java.sql.Date, but when I try to print the time value (from persistent class ) it prints 24.00 (i.e, it is taking a constant value of 12 am ...

19. specifying an SQL WHERE condition when mapping a collection    forum.hibernate.org

I was wondering if it were possible to specify a runtime variable in the SQL where condition when mapping a collection. The document explains the usage of the tag (6.2. Mapping a Collection), but I can't find anything on how to specify a variable in the actual where clause. I really appreciate any help you can afford me. Thanks Shafiq ...

21. Mapping a CIDR (Classless Inter-Domain Routing) SQL type ?    forum.hibernate.org

Hibernate version: 2.1.3 Hello I am using the sql type CIDR to store various ip ranges and perform builtin Postgresql functions like broadcast(), netmask() and such. When I use Middlegen to generate the POJOs and the mapping files, it does not seem to understand this type, then reverts to java.lang.Object. This causes an Hibernate property exception, saying this property has a ...

22. Executing simple non-mapped SQL    forum.hibernate.org

I'm in the process of refactoring a dao with a jdbc implementation to hibernate. In the dao there are some simple queries that don't have associated pojo's. In this case, where I want to execute a simple select statement, possibly even to just ping the database, do I need to get the connection form the session and use the jdbc api? ...

23. sql-query mapping problem    forum.hibernate.org

I have below element present in one of the hibernate mapping file. Code: select metaobjectno, structureno, name, description from metaobject where structureno = :structureno Metaobject class definition is something ...

24. Sql querys that do not map to objects    forum.hibernate.org

Is there a way to map an sql statement to a java class that doesnt exist. The reason I would want to do such a thing is because the reporting portion of my application returns result sets that do not directly map to domain objects. Here is a simplified example of what I would like to do. Code:

26. Named SQL Query in the Mapping Files    forum.hibernate.org

Hi all, I am having a problem creating a named sql query in a hibernate mapping file. If i take out the element then there is a different error which i have posted below the original exception output below.. i have searched but i cannot find any mapping examples that include named queries.. can anyone help me out here.. thanks ...

27. Using mapping with problem    forum.hibernate.org

I have a mapping between a few tables to represent a Configuration and a SettingType value stored in a separate table. The works fine using standard session lookups using the ID but when I try to use a sql-query to load the object with some custom sql it blows up when it tries to bring in the columns from the ...

28. SQL for Parent/Child relationship?    forum.hibernate.org

29. sql in hibernate without mapping    forum.hibernate.org

List results = session .createSQLQuery("SELECT col1, col2 FROM table1") .addScalar("col1", Hibernate.STRING) .addScalar("col2", Hibernate.INTEGER) .list(); for (Iterator iter = results.iterator; iter.hasNext(); ) { ...

30. EJBQL to sql mapping    forum.hibernate.org

hi all! i have a problem with the following setup. i have two entities mapped to exactly two tables in oracle. i would like to generate list with dynamic filtering, so i have an ejbql fragment (select prop1, prop2.prop1, prop3 from entity1) creating the where condition at runtime. i have problem with the sql hibernate generates from this code. the problem ...

31. Mapping an object to an SQL [SOLVED]    forum.hibernate.org

Hi Ajay, how about creating a native query and supply a result-set-mapping? This works for me when using JPA, but there's also a plain hibernate solution for this, see the docs, section 16.4 (http://www.hibernate.org/hib_docs/reference/en/html_single/). Note that this solution requires the Data-class is an Entity. Something (in your orm.xml) like: Code:

32. Hibernate SQL Table mapping problem    forum.hibernate.org

Hello, I have a question about the mapping of hibernate. There are attributes for defining the table name and the column name. In my case hibernate seems to completely ignore them. I have the tables created in uppercase in my database. Hibernate says, that the tables were not created. If I tell hibernate to create the tables, it creates the tables ...

33. Named SQL Query in Mapping - beginner question    forum.hibernate.org

I read through the Introduction chapter today (ok - I skimmed throught it) but couldnt find any answers to my questions there, nor in the FAQ. Im a newcomer to Hibernate and trying to finish off what someone started :( I have a mapping file as below for a User (a bit stripped down for clarity). User.hbm.xml ----------------

34. Many-to-one not mapped in sql-query with return-join    forum.hibernate.org

We had a sql-query which was previously running until I added a many-to-one property to the class the query returns. It seems that query tries to find a column for the joined object (ent.changeReason) instead of using the return-join object. I think this is the case as if I uncomment the commented line at the bottom of the query {ent.changeReason} corresponds ...

35. How to best map in Hibern. an java enumeration to SQL table?    forum.hibernate.org

Assume I have a java class with an enumeration element public class myRecord { ... public enum state; ... } How do I define the corresponding SQL table column? Assume I define it as int: How do I specify in Hibernate a mapping enumvalue1 <-> 1 enumvalue2 <-> 2 enumvalue3 <-> 3 Peter

36. mapping problem due to sql-delete and check="param"    forum.hibernate.org

Author Message GlWy Post subject: mapping problem due to sql-delete and check="param" Posted: Thu Mar 26, 2009 9:12 am Newbie Joined: Tue Mar 24, 2009 6:35 am Posts: 3 greetz, We have upgraded hibernate and spring as follows: hibernate --> hibernate spring --> spring One of the things to be done was adding attribute check="param" to the sql-delete in ...

37. mapping problem due to sql-delete and check="param"    forum.hibernate.org

Author Message GlWy Post subject: mapping problem due to sql-delete and check="param" Posted: Thu Mar 26, 2009 9:27 am Newbie Joined: Tue Mar 24, 2009 6:35 am Posts: 3 greetz, We have upgraded hibernate and spring as follows: hibernate 3.0.5 --> hibernate 3.3.1 spring 1.2.7 --> spring 2.5.6 One of the things to be done was adding attribute check="param" ...