List 2 « Map « JPA Q&A





1. Can i use a set or List in this example?    stackoverflow.com

public class Student implements java.io.Serializable {

private long studentId;
private String studentName;
private Set<Course> courses = new HashSet<Course>(0);

public Student() {
}

public Student(String studentName) {
    this.studentName = studentName;
}

public Student(String studentName, Set<Course> courses) {
 ...

2. Hibernate Bi-Directional List Association    stackoverflow.com

I'm sure there must be thousands of examples demonstrating this association but I can't seem to find one anywhere. I have a one-many relationship from Parent-Child and a many-one relationship from Child-Parent:

class ...

3. Hibernate query where item in list    stackoverflow.com

Can anyone suggest the correct syntax for a where clause using in applied to a list? The following query in an .hbm file generates a parse exception:

<query name="Nutrient.findNutrients1">
    <![CDATA[from Nutrient ...

4. Hibernate: Sorting a list without 'touching' the database    stackoverflow.com

I've got a many-to-many relationship in my database and I'm using Hibernate to retrieve a single row from the left hand side of the relationship. I then just call the ...

5. hibernate not mapping the bean, returning Object List    stackoverflow.com

hi am new and hibernate is driving me crazy full time. i hv 2 tables one-2-one mapping. when i join only these 2 these two then hibernate is not mapping and when ...

6. Adding a position column to a child table in MySQL for mapping to a Java List with Hibernate    stackoverflow.com

Hibernate requires a position column on a table that will be mapped to a List. To evolve an existing table, not only does the column need to be added, but it must ...

7. Hibernate One To Many Unidirectional Mapping List    stackoverflow.com

I have one-to-many relationship between parent and child Java objects. The parent object uses java.util.List that stores multiple child objects. The problem I am experiencing is when updating the parent object ...

8. How Would One Find a Dependency-Order list of Tables to Delete for Test Data?    stackoverflow.com

I have a test suite that needs to delete any existing data in my local MySQL test instance for a large number (but not all) of the tables in the system.

 ...

9. Null list returned from hibernate query with embedded id    stackoverflow.com

I have an entity with an embedded key. The entity has only the key as a field and the key has 7 fields, some of which can be null. When I ...





10. Hibernate support for Oracle Array list joins    stackoverflow.com

Oracle supports a query syntax where a table is joined to an Oracle collection type (Nested table or VARRAY). This semantic can be used instead of the in (1,2,3) syntax in ...

11. How to deal with a List of Objects after a Hibernate query against a single entity    stackoverflow.com

After calling list() on a Hibernate Query which you expect to just return a list of Foo objects (see example below), how best would you deal with this situation?

Query ...

12. Hibernate filter on an entity list but only retrieving one of the attributes    stackoverflow.com

If I have an entity called Foo that looks a little like this:

@Entity
public final class Foo {
    private int id;
    private String name;
   ...

13. How to make a list (containing of objects) persistent    stackoverflow.com

First of all, as you can see, I work in Java and specifically in NetBeans IDE. So, I have a class Person that extends two classes : Trainer, and Athlete. In the main, ...

14. How do I create a mapping file for an ordered List with Hibernate?    stackoverflow.com

I have a simple Java model where a ListHolder holds a List that in turn can hold ListHolder objects:

public class ListHolder {
    private List<ListHolder> list;
}
My approach for a ...

15. hibernate validiate list of integer    stackoverflow.com

I have a list of integer like this:

private List<Integer> indexes;
Is there a way to valid individual member to be in a range of 0-9? I see @Range and @Valid but ...

16. Why does hibernate/jpa set @OrderColumn field to null for a removed element in a mapped list before deleting it?    stackoverflow.com

I'd like to map a tree structure of "chapters". Every chapter has a reference to its parent, and a ordered list (by "position") of subchapters. With JPA 2.0, Hibernate 3.5, the entity ...





17. Getting Hibernate mapping exception with java.util.list    stackoverflow.com

HI, I am getting a problem with a data member of a class. The data member is ContactNumbers. The ContactNumbers is a java.util.list and I am getting errors when hibernate maps the ...

18. Selecting by specific elements in a list in HQL    stackoverflow.com


I'm implementing a "QueryEngine" design pattern for dynamic queries
on with loose connection to a Query Language (Like LINQ).
I am having a hard time writing the HQL for a specific elemt from ...

19. Adding IN clause List to a JPA Query    stackoverflow.com

I have built a NamedQuery that looks like this:

@NamedQuery(name = "EventLog.viewDatesInclude",
        query = "SELECT el FROM EventLog el WHERE el.timeMark >= :dateFrom AND "
 ...

20. How to get list of 10 random unique objects with Hibernate?    stackoverflow.com

Does anyone have HQL query on how to get list of 10 random unique objects from the database? It should be done in database not in application. I'd like to get something ...

21. Criteria Showing list size 1 when there are no records    stackoverflow.com

I have the doubt regarding the hibernate criteria. I'm getting list size as 1 when there are no records in the list.When i print the list it shown as list[null]. My code:

final Double ...

22. Hibernate Many to Many Bidirectional Mapping with using Java List    stackoverflow.com

I am trying to make a many to many example with hibernate using java List. My codes are as follows, I am getting some erros. If someone can help me to ...

23. Play: What does adding a "many" object to a "one" list property do?    stackoverflow.com

This question probably has a lot to do with Hibernate, but since Play obfuscates Hibernate and i don't know it anyway... Take the following sample code: User has many Posts.

public class User ...

24. Placing List Index when using List in Hibernate    stackoverflow.com

I was using a Set but now due to a widget restriction, I need to use a list.a a sample of my mapping file using A SET and a List are ...

25. How do you make a join in Hibernate return a list instead of a two-dimensional list?    stackoverflow.com

Hopefully, this is a simple question. I'm doing a join in HQL along the lines of:

FROM Apple a, Orange o WHERE a.price = o.price AND a.price > 1.99
When I do this, I ...

26. Hibernate foreign key relation - list() makes unnecessary sql queries - setMaxResults ignored    stackoverflow.com

First of all, this is the first time that I use Hibernate so my questions might seem naive. I have two tables, DsJobs and DsEvents. Events has a foreign key relationship on ...

27. Wrong number of children items returned in join fetch on JPA    stackoverflow.com

I have a JPA OneToMany association

@OneToMany(mappedBy = "playlist", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@IndexColumn(name = "intSequence")
private List<Track> tracks;
in class Album. When I am using join fetch ...

28. How to update the list after delete an item of that list    stackoverflow.com

It will take a moment for me to explain this, so please stay with me. I have table NewsFeed that has OneToMany relationship with itself.

@Entity
public class NewsFeed(){
    ...

29. Looking for effecient way to store nested data with hibernate    stackoverflow.com

I've been trying to find an efficient way to represent nested data in java/hibernate. My initial solution was a parent/child list with a self referencing join, but there are obvious ...

30. jpa removing item from list    stackoverflow.com

I have 1-N relationship (object has a list) and want remove one item from the list. What is the right way of removing item in the list with JPA? Do I have ...

31. Accessing list-based records from main record    stackoverflow.com

I have a table - let's call it AAA, which has a one-to-many definition to an additional table, assigned BBB. It looks something like that:

public class AAA
{
...
   @OneToMany(orphanRemoval=true, fetch=FetchType.LAZY, ...

32. How can i retrieve a list of entites + an additional value with JPA/Hibernate?    stackoverflow.com

There are two tables, report and reportcomment. Every reportcomment is assign (via foreign key) to a report, therefore a report has zero to many reportcomments.
If I need a list, that gives ...

33. Selecting where an entity contains a list thats a subset of another list    stackoverflow.com

I am writing a JPQL query and i have the following scenario. I have a Question entity which contains a list of Tags. I would like to select all Questions ...

34. Type mismatch: cannot convert from List to ILogin    stackoverflow.com

private ILogin results;

    public ILogin authenticate(Login login) {
        System.out.println(login);
        System.out.println(login.getEmail());
     ...

35. nhibernate delete multiple records by list of id's with HQL statement    stackoverflow.com

I want to delete multiple records of a certain entity where the id of the entity is in the list of ids I have. I am trying to perform this action ...

36. jpa query where the entity on a collection is in a list    stackoverflow.com

Probably not best described in the title but i have 3 entities Order -> OneToMany -> OrderProduct and OrderProduct <- ManyToOne -> Product Product <- OneToMany -> OrderProduct , my native query that ...

37. List items per sales using JPA    stackoverflow.com

I have two entities :

Items(id, user_id, title, price);
Purchases(id, item_id, user_id, date);
Using JPA, I'd like to list all the items that have been purchased more than X times, ordered by their purchased ...

38. Hibernate HQL : where clause with list    stackoverflow.com

I am a little confused with Hibernate. My problem is the following: I have an object in a table on my database, and this object is associated to different comments (stored in another ...

39. Cast Hibernate result to a list of objects    stackoverflow.com

I have a hibernate call in my DAO that looks like this

List<Associate> associate = (List<Associate>)session.createSQLQuery("SELECT * FROM associates WHERE fk_id = :id AND fk_associate_id = (SELECT id FROM users WHERE fk_user_type ...

40. Convert a list of IDs into a list of objects with an ORM like Hibernate    stackoverflow.com

In web applications it is common to send a list of IDs to the server when selecting elements of a collection. There could be a HTML form representing a course and ...

41. Hibernate - Retrive List of files without Blob byte array[]    stackoverflow.com

I have a table Uploads that stores uploaded files as blobs and it also stores other important file information. It has the obvious fields such as

file_id INT
file_mime VARCHAR
file_size INT
file BYTE[]
...
In ...

42. Finding an Entity based on a list of Entities    stackoverflow.com

Suppose we have Group -> Member (ManyToMany) With a given set of Member - what's the most practical way to find if a Group has been created for exactly those members? (No ...

43. When selecting a subset of a table, hibernate does not auto cast it into the business domain object in a list    stackoverflow.com

When i am selecting a full table

i.e. select * from product
, Hibernate returns me a list of Product objects. However, when i am selecting only a subset of ...

44. Controlling result list from org.hibernate.Query.list when using joined subclass    stackoverflow.com

I have a User class, which is mapped to the "USERS" table in database with Hibernate. There is also a class ApplicationUser, which extends the User class and is mapped as ...

45. Hibernate Get List of a table's attribute    stackoverflow.com

Hello everybody and sorry for the rather confusing question-title. I have a Hibernate Class configured using Annotations. This class has a String-attribute which contains the name of a company. What i need is ...

46. Hibernate criteria: search by content on a property list in an entity    stackoverflow.com

I want to search by content on a property in an entity I have a simple class to define a User:

@Entity
public class User {

    @Id
    @Column(name ...

47. Hibernate annotations for maping a List of entities    stackoverflow.com

Using Hibernate Annotations, what is the best way to map a list of entities to another entity, when the entity in the list does not contain a reference back? For instance, here's ...

48. Assign rows of a result set with same id into a Java list using Hibernate    stackoverflow.com

I'm using Hibernate to retrieve some data from a database. The result set returned by the SQL query I'm using, is something like the following:

SourceId | TargetId
1     ...

49. How to store the same entity in mulitple lists in Hibernate using JPA    stackoverflow.com

Im very new to Hibernate so this will probably a easy task for you guys. As the Topic says I'm trying to reference the same entity in multiple Lists. But when I ...

50. In Hibernate, is it better to return a single Object or a List with only one element?    stackoverflow.com

Say I have class Foo and I have a FooRepository class with a method select(). The select() method returns a List<Foo> collection of objects. Now, I want a select_one() method that always returns ...

51. How to use list of value in where clause    stackoverflow.com

I am using hibernate3 in my java application. I have to find the list of value from oracle using hibernate. So my query is like Ex:

List<TestClass> selectedpins =DAO.findAll(from register where ...

52. Hibernate - TypedQuery.getResultList() returns a list of the same object    stackoverflow.com

Here is a more and maybe better description of the problem: I do a simple select query. The returning list contains the exact number of records/objects as if I do the same ...

53. query.list gives wrong result for sqlquery    stackoverflow.com

I have one sqlquery which works fine when pasted to sql server explorer, but when hibernate query.list call is made the list gives me zero size list. Below is the code: Query ...

54. In which form the org.hibernate.Query returns the result upon calling the list method?    stackoverflow.com

My Java code is ,

Query q=session.createSQLQuery(" { call procedureSample(?) }");

List list=q.list();
The procedure procedureSample returns three values, like (int,string,int). 1.How can I get the results ? 2.Whether I need to create the bean? If ...

55. Hibernate how to remove item from list    stackoverflow.com

I have been facing some challenges of understanding how list are managed in hibernate. I have looked at the following post: hibernate removing item from a list does not persist ...

56. Create list of objects from subselect in select with HQL    stackoverflow.com

Is it possible to create a object hierarchy with non-entity objects and a 1:n relation from a HQL-Query? Note: Creating Analysis objects, when fully qualified with namespace is no problem. The only ...

57. hibernate mapping for list of classes    stackoverflow.com

I have a class A{a_id,other properties List) and class B{b_id,other properties). I have different tables for A and B and mapping table A_B(a_id,b_id,displayorder).Entries in table are constant . We can insert/update/delete from ...

58. In hibernate is there a way to retrieve a list of entities ordered by a property of a many-to-one relationship object    stackoverflow.com

I have a many-to-one relationship as follows

    <hibernate-mapping default-lazy="false" package="com.my.sample.data">
  <class name="Person" table="person_table">
<!-- other stuff -->
 <many-to-one class="Company" column="p_id" fetch="join" insert="false" name="company" update="false" not-found="ignore" not-null="false" />
Company ...

59. Calling hibernate query list() method generates errors    stackoverflow.com

I'm trying to debug someone's codes. But I am not an expert of hibernate so I'm asking your help about this. I am trying to retrieve a list of jobs from the ...

60. How do I sort list with criteria in hibernate    stackoverflow.com

I am new to Spring3 and Hibernate the following code works great but I am trying to find a way to have my list returned in sort order by the date ...

61. Using Hibernate to persist a List>    stackoverflow.com

I have the following Java Collection

List<Map<String, Object>>
I've written a custom converter class which can flatten this down to a List of MyEntity (where MyEntity is basically String, Value, Java type, parent ...

62. How to annotate to allow for searching a List field using Hibernate Search    stackoverflow.com

Let's say I have a domain object that looks like this:

@Entity
@Indexed
public class Thingie implements DomainObject {  

private Long id;        
private Integer version;

private String ...

63. Hibernate ElementCollection with List: Wrong FETCH?    stackoverflow.com

Dear All, I have the following problem: from one side I need to have a list of Embeddable, and on the other side i need to persist it with fetchType.EAGER. I am ...

64. Search records having comma seperated values that contains any element from the given list    stackoverflow.com

I have a domain class Schedule with a property 'days' holding comma separated values like '2,5,6,8,9'.

Class Schedule {
   String days
   ...
}

Schedule schedule1 = new Schedule(days :'2,5,6,8,9')
schedule1.save()

Schedule ...

65. JPQL: how to retrieve a List of data and set a value for each data in that list    stackoverflow.com

So I have a entity Notification, that has a boolean attribute readStatus to determine of a notification has been read or not. When I click a button, I want to write ...

66. Why can't I get result list, from a query?    stackoverflow.com

I want to login my users only if their account is activated, but for some reason the query that should return me the user (I call it Role in my program) ...

67. nhibernate - find object with the same list    stackoverflow.com

Let us say I have an object that contains an IList of some other objects. Is it possible to find objects with the same IList efficiently? What would you use HQL ...

68. Hibernate, List    stackoverflow.com

I seem to have problems with mapping a List in Hibernate. In our project there a class Card with contains a class Answer with Answer containing a List<String. Is a List<String> mappable ...

69. GORM Generic List    stackoverflow.com

I'm working with grails since a while. There is something I still don't know how to implement correctly. I have a domain class (let's say User) which contains a List which can ...

70. Hibernate Criteria query: problem getting a list of objects with a m..n relationship where child table does not have a certain property    stackoverflow.com

I have the following tables

CREATE TABLE "COMPANIES" (
    "ID" NUMBER NOT NULL ,
    "NAME" VARCHAR2 (100) NOT NULL  UNIQUE
) 
/

CREATE TABLE "COMPANIESROLES" (
  ...

71. Hibernate list mapping question    stackoverflow.com

I am aware this code is rather messy. Copying an extraction of one list to another I'm pretty sure is not the most elegant of solutions. However I just want to ...

72. How to set up "one-to-many" mapping of List objects by XML without index column    stackoverflow.com

I can set up "one-to-many" mapping of List objects by using annotations, however using XML is not. Could you tell me how to set up using XML mapping. Any help will ...

73. correct result type (not list)    stackoverflow.com

How am I supposed to specify the result type of query like this:

em.createNativeQuery("SELECT u.login, s.name FROM Student s, Users u").getResultList();

74. Saving huge lists of objects taking lot of time    stackoverflow.com

I am trying to do some big lists of object saving using hibernate.. problem is before saving I need to confirm if a record with same field data already exists if yes ...

75. how to select specified fields, and return an object (defined by user) list - (hibernate)    stackoverflow.com

Hibernate api doc introduces the Criteria and Projections classes, which can help select specified fields of table and return an Object list. BUT, i want to get an class A's list ...

76. Hibernate List configuration    stackoverflow.com

Hey everyone! I'm still trying to implement hibernate collections. Right now i've run into a big problem. There arent any errors, but hibernate just doesnt fetch the collection. Maybe someone can look ...

77. Is there a way to update a database field based on a list?    stackoverflow.com

Using JPA, I have a list of entries from my database :

User(id, firstname, lastname, email)
That I get by doing:
List<User> users = User.find("lastname = ?", "smith");
And I'd like to update all in ...

78. JPA passing list to IN clause in named native query    stackoverflow.com

I know I can pass a list to named query in JPA, but how about NamedNativeQuery? I have tried many ways but still can't just pass the list to a NamedNativeQuery. ...

79. Cant fetch more than 50000 records in hibernmate HQL List    stackoverflow.com

I m using struts hibernate i have one table which have more than 50K records, but i cant fetch that records in arraylist, when i m trying it always fire me java heap ...

80. Select all items from a list in hibernate    stackoverflow.com

I am new to hibernate, so don't shoot me if this is a noobquestion. I have a list of productIds and I want to get all the products from my db with ...

81. Mapping a comma-separated list of primary-key ids in a string to actual JPA entities    stackoverflow.com

I understand storing a list of primary-key ids in a field of a database as a comma-separated list is not the recommended approach for a many-to-many relationship between tables. However, for ...

82. how to get a result list from query using Object Query Language    stackoverflow.com

I'am using JPA/Hibernate I want to know how can I use createquery to retrive a list . I have tried :

EntityManagerFactory emf=Persistence.createEntityManagerFactory("JiraMapPUKPI");  
EntityManager em= emf.createEntityManager();
EntityTransaction entr=em.getTransaction();
entr.begin();
Query multipleSelect =em.createQuery("select distinct k.kpiName FROM ...

83. hibernate list of parameters    stackoverflow.com

i need to write a general function that handle queries. the function get List that hold parameters that is sent to the query. how i implement that in hibernat. to be ...

84. how to write the JPQL to get list of data by day, month or year    stackoverflow.com

here i'm having trouble getting list of data by either day , month or year in eclipse. i'm using entity manager to pull info from mySQL database. i'm creating a web form ...

85. JPA or Play Framework list from query joining 2 tables    stackoverflow.com

Mainly I work with JSF so am totally new to this annotation subject If anyone can help I wanna a list from this query

SELECT  f.CODE  ,f.NAME || '-' || e.NAME ...

86. How to set list of values as parameter into hiberante query?    stackoverflow.com

Example I have query "select cat from Cat cat where cat.id in :ids" and I want to set ids to list (1,2,3,4,5,6,17,19).

session.createQuery("select cat from Cat cat where cat.id in :ids").setParameter("ids", new ...

87. Hibernate, parameterLists and lists of objects    stackoverflow.com

I have a list of Products (Products is id, name, price etc.). The products are referred to by id (not linked in the hibernate xml) in another table reporting. I want to have ...

88. Store List in hibernate as Serializable object    stackoverflow.com

Normally we store a List in database by the hibernate mapping:

<list name="userItems" cascade="all" lazy="false">
    <key column="user_date_id"/>
    <index column="idx"/>
    <one-to-many class="UserItem"/>
</list>
Is there any ...

89. How to Change Hibernate Collection Mapping from Set to List    stackoverflow.com

I am using eclipse Tools to generate my Annotated Domain Code Classes. For the One to Many & Many to Many Relationships, the code generated used Set type for collections. I want to change ...

90. Issue with a List using PlayFramework and JPA    stackoverflow.com

I am working on a project using the Play!Framework, and I an encoutering some issues with JPA. It seems that it doesn't save my List, or doesn't manage to retrieve it ...

91. Create new NamedQuery or build new List to return field values?    stackoverflow.com

In general, is it a better practice to write a new NamedQuery which selects a field,

@NamedQuery(name="getEntityField",
            query="select e.field from Entity ...

92. How to persist a List of Entities from multiple Subclasses    stackoverflow.com

I'm using hibernate and want to create a property that contains a list of Entities from different classes. Each class inherits the same Interface/Abstract. Can this be done with hibernate or jpa ...

93. Java classcast exception which involves a List returned by Hibernate    stackoverflow.com

First off, I am maintaining some code that I didn't write and I'm fairly new to Java and Hibernate. I recently tweaked a query that runs in a Hibernate session. ...

94. Hibernate criteria list iterating    stackoverflow.com

I have the following section of code that I want to use to return a collection of my object:

Session session = HibernateUtil.getSession();

List<MyObj> myObjList = (List<MyObj>) 
      ...

95. detached list from a query    stackoverflow.com

I want to run a query, but the results should be read only. And they might need a refresh, and I don't want to refresh each element in the list. I'd ...

96. Result for a projection's list with a hibernate criteria    stackoverflow.com

I'm using a criteria with projections to extract 2 columns from my database. However, I would like a result as 2 lists of simple elements instead of 1 list of elements. My ...

97. java hibernate query.list returns empty list    stackoverflow.com

I am using hibernate with JPA annotations and Jboss transaction manager I build the session factory open up a session and create a query when i use query.list it always returns ...

98. Hibernare query returns empty list    stackoverflow.com

@Entity@Table(name = "temp_detail", schema = "public")
public class TempDetail implements java.io.Serializable {

    // Fields

    private Integer theId;
    private String tempData;

    ...

99. Can Hibernate Custom query return a Map instead of a List?    stackoverflow.com

Is it possible to return a map instead of a List from a custom JPA Query? I know if is possible from the Entities themselves. In my case I have a custom ...

100. storing sorted list inside ehcache    stackoverflow.com

I'm new to ehcache and I can't seem to find exactly what I need. I am using hibernate and have one large table (500k + items) that I need to query ...