List 1 « Map « JPA Q&A





1. How to persist a property of type Listin JPA    stackoverflow.com

What is the smartest way to get an entity with a field of type List get persisted?

Command.java

package persistlistofstring;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Persistence;

@Entity
public class Command implements ...

2. How to map many-to-many List in Hibernate with a Link Table    stackoverflow.com

I would like to map a many-to-many in Hibernate using a link table. I have two classes, Parent and Child class, for example:

public class Parent{

private List<Child> _children;

//...getters and setters
}
I use a ...

3. Can Hibernate return a collection of result objects OTHER than a List?    stackoverflow.com

Does the Hibernate API support object result sets in the form of a collection other than a List? For example, I have process that runs hundreds of thousands of iterations in ...

4. Mapping a bidirectional list with Hibernate    stackoverflow.com

I don't understand the behavior of Hibernate when mapping a bidirectional list. The SQL statements that Hibernate produces seem not optimal to me. Can somebody enlighten me? The scenario is the following: ...

5. Hibernate HQL with list getters    stackoverflow.com

I have a Hibernate entity, with a getter that is mapped as a @OneToMany:

@Entity
class Parent extends BaseParent {

    @OneToMany(cascade = {CascadeType.ALL}, mappedBy = "parent")
    public ...

6. Hibernate: Removing item from a List does not persist    stackoverflow.com

I am having trouble when removing an item from a list. The list is defined in a superclass, but the Hibernate annotations are applied to property accessors in a subclass. There ...

7. Where can I find a list of all HQL keywords?    stackoverflow.com

Where can I find a list of all HQL keywords?

8. Map a list of strings with JPA/Hibernate annotations    stackoverflow.com

I want to do something like this:

    @Entity public class Bar {
        @Id @GeneratedValue long id;
      ...

9. Hibernate for getting a list of primitive integers for subselect    stackoverflow.com

Isn't there a way with Hibernate to return a list of (primitive) values from one column in a table? I need this for a subselect where I only want rows ...





10. How do I sort the List by a property of the Objects in the collection?    stackoverflow.com

So I've resigned myself to not being able to use the order of a List reliably because hibernate reverses it and everyone says don't do it, so I've added a field ...

11. How to fetch hibernate query result as associative array of list or hashmap    stackoverflow.com

I am developing an application in struts 2 and hibernate 3. I have 3 tables

  1. Inspection
  2. InspectionMission
  3. Timeline
Inspection is associated with InspectionMission and InspectionMission is associated with Timeline. Now I have following problem. I have written ...

12. How do I map a nested collection, Map>, with hibernate JPA annotations?    stackoverflow.com

I have a class I am not sure how to annotate properly. My goal for Holder::data:

  • List should maintain order not by comparator but by the natural ordering of the elements ...

13. Defining the order of a list    stackoverflow.com

I have the following problem. I have three classes, A, B and C. A contains a OneToMany relationed list of B:s. B contains a ManyToOne relation to C. C contains a ...

14. List as a named parameter in JPA query using TopLink    stackoverflow.com

In the following JPA query, the :fcIds named parameter needs to be a list of integer values:

@NamedQuery(name = "SortTypeNWD.findByFcIds", query = "SELECT s FROM SortTypeNWD s WHERE s.sortTypeNWDPK.fcId IN (:fcIds)")
Quite logically, ...

15. nhibernate hql list    stackoverflow.com

I have 3 classes :

 public class Transformation
{
        private int Id;
         private int Type;
  ...

16. hibernate collection mapping with list and super entity class    stackoverflow.com

here i am again in my self learning hibernate and personal experiment project to gain more understanding. Here is the description of my environment: i have a super model entity that all ...





17. Lazy query.list() in Hibernate?    stackoverflow.com

I am using Hibernate 3.3.2 GA + Annotations. Is there a way get a lazy list back when calling list() on a query? The documentation (19.1.3) remarks:

list() does ...

18. When I persist, the entity doesn't show up in the list view    stackoverflow.com

I'm trying to add a new entity and then after a successful commit, redirect them to the list action. Here's a summary of what I'm doing:

@Name("offerAction")
@Scope(ScopeType.CONVERSATION)
public class OfferAction implements Serializable {
  ...

19. How to map in XML List field with hibernate    stackoverflow.com

I googled all day and I cant find one good example how to map this kind of objects:

class Parent{
    private Integer parentId;
    private String parentName;
 ...

20. Mapping a list in hibernate by ordering instead of an index-field    stackoverflow.com

This works:

<hibernate-mapping>
    <class name="Train" table="Trains">

        <id column="id" name="id" type="java.lang.String" length="4">
            ...

21. Hibernate: best collection type to use - bag, idbag, set, list, map    stackoverflow.com

I am looking for what most people use as their collection type when making one-to-many associations in Hibernate. The legacy application I am maintaining uses bags exclusively, but keeps them as ...

22. How to convert list type in Java hibernate    stackoverflow.com

In java application I use hibernate criteria queries, for example:

Criteria criteria = session.createCriteria(Any.class);
...

List<?> list = criteria.list();
and I definetly know that result list contains only objects of type Any but I don't ...

23. Hibernate implementation of simple many-to-many relationships - Dictionary or List?    stackoverflow.com

I have 3 DB Tables: Person, Address, and PersonAddress. Person Address is a simple join table (only stores the IDs of Person and Address). In my domain model, I have Person and ...

24. Setting a parameter as a list for an IN expression    stackoverflow.com

Whenever I try to set a list as a parameter for use in an IN expression I get an Illegal argument exception. Various posts on the internet seem to indicate that ...

25. Is it valid for Hibernate list() to return duplicates?    stackoverflow.com

Is anyone aware of the validity of Hibernate's Criteria.list() and Query.list() methods returning multiple occurrences of the same entity? Occasionally I find when using the Criteria API, that changing the default fetch ...

26. How to project only two columns and list them? (Nhibernate)    stackoverflow.com

Given the table structure below, how do you project x and y only with nhibernate? How do you list the results, what is the type of the resulting list?

//Table structure, mapped ...

27. Problem selecting the value from a JComboBox binded to a list    stackoverflow.com

I have a JComboBox binded to an observable list (result of a jpa query) in a java desktop application. It gets all the values from that list and displays them correctly, ...

28. EJB-QL Query List inside Object    stackoverflow.com

I'm attempting to write what should be a simple (I hope) EJB-QL query. Here are my objects:

public class Room {
     private String name;
     private ...

29. HQL: get a list where a join contains nulls    stackoverflow.com

I have three objects.

public class ParentClass
{
public virtual Guid ParentClassId { get; set; }
public virtual IList<Child> Children { get; set; }
}

public class Child
{
public virtual Guid ChildId { get; set; }
public virtual ParentClass ...

30. How to get Hibernate JPA to manage list index automagically?    stackoverflow.com

How do I setup a basic OneToMany relationship using a List and get Hibernate JPA to manage the sequence index number of the list automagically? Can this be done? This is my ...

31. Getting list in order, mapped by join table    stackoverflow.com

I have two entities that have a many-to-many relationship; they are mapped with annotations @ManyToMany and @JoinTable. In the database join table I also have "order" column which would indicate in ...

32. Searching object property in a predefined list using HQL    stackoverflow.com

I'm trying to make a query in HQL that see if the id of a person is in a list of predefined ids. For example, I would like to find all persons ...

33. Hibernate displaytag big lists    stackoverflow.com

I'm using displaytag to build tables with data from my db. This works well if the requested list isn't that big but if the list size grows over 2500 entries, fetching ...

34. Get fresh data for a list of entities    stackoverflow.com

We're using jpa with Toplink as an implementation and came up with a problem about refreshing lists of entities. Basically this is the scenario:

private List<Entity> findAll()
{
    final String sql ...

35. JPA List field without another Model    stackoverflow.com

I would like to know if there is anyway I can do something similar to the following thing with JPA:

@ManyToMany(cascade=CascadeType.PERSIST)
List<String> trackKeywords;
Or do I need to create another model with a String ...

36. How to query a property of type Listin JPA    stackoverflow.com

Lets say we have this JPA-annotated class, with a property of type List. This code is currently working fine.

@Entity
public class Family {
    ...
    @CollectionOfElements(targetElement=java.lang.String.class)
  ...

37. NHibernate - Exclude a property from a projection list (select clause)?    stackoverflow.com

I have classes that look like this

public class Agreement
{
    public virtual string ArrgKey { get; set; }
    public virtual string SubjectCode { get; set; }

 ...

38. Hibernate list operation question    stackoverflow.com

I'm working on a utility to update a list of entities in a database as a group. The database contains a list of entities. The result of the update is a ...

39. List of list of named parameters in EJBQL/HQL    stackoverflow.com

I'm trying to execute a long 'INSERT ON DUPLICATE KEY UPDATE' with up to a few thousand rows in a MySQL+JBoss+Hibernate application. It looks something like:

INSERT INTO Table (field1, field2, field3) ...

40. Trouble creating unique table of Strings when persisting List    stackoverflow.com

Suppose I have an entity:

@Entity
public class AnEntity implements Serializable{
   @ElementCollection
   private List<String> strings = new Vector<String>();
// other stuff
}
I am using EclipseLink(JPA 2.0). The strings in this List ...

41. Value in db is a hyperlink, and wish to list based on the value of the hyperlink    stackoverflow.com

I have made my parameter as a hyperlink. Now i want to click the hyperlink and then list of all information of that value in hyperlink. How do i do that?


From Account No ...

42. Grails Domain Class Dynamic List As A property    stackoverflow.com

Let's say I have a domain class called ShopCategoryPageTab. And I have a domain class called Product. I want ShopCategoryPageTab to have a list of Products. However, this list is not static, ...

43. Where can I find a complete (!) list of all Hibernate events?    stackoverflow.com

Hibernate supports several events through listener interfaces. I could find all interfaces in the API docs. But i couldn't find a complete list of the corresponding event names.
Any idea ...

44. get the size of a list in a property    stackoverflow.com

I have a class A which have a list of B elements. In my A class i would like to add:

int size;
which will be valued with the number of B elements. So ...

45. JPA + Hibernate + Native Query + custom list of dtos from the resultset    stackoverflow.com

My native query below is working fine oracle sqlplus. But through JPA native query, giving following error: [ERROR] org.hibernate.util.JDBCExceptionReporter - ORA-00923: FROM keyword not found where expected Native Query


SELECT sch.school_name, term.term_name, count(material.MATERIAL_ID), ...

46. hibernate - Postgres- target lists can have at most 1664 entries    stackoverflow.com

We are using hibernate, postgres 8.3x Our entities are many to one mapped with eager fetching. We have multiple associations with Many to one mapping. As we added new columns to any other existing ...

47. A concise, clear list of what is new in JPA2?    stackoverflow.com

Does anybody know of a good list of what is new in JPA 2? Not what is new with Hibernate/TopLink in the version that supports JPA 2 but what ...

48. Hibernate, EHCache, Read-Write cache, adding item to a list    stackoverflow.com

I have an entity that has a collection in it. The collection is a OneToMany unidirectional relationship storing who viewed a particular file. The problem I am having is ...

49. How to recover data from a table, and store that into list?    stackoverflow.com

How can I get ALL the data from a table of my DB (mySQL) using hibernate, and store the output into List of Objects? I'll use this List, to populate a JTable. ...

50. Passing empty list as parameter to JPA query throws error    stackoverflow.com

If I pass an empty list into a JPA query, I get an error. For example:

List<Municipality> municipalities = myDao.findAll();  // returns empty list
em.createQuery("SELECT p FROM Profile p JOIN p.municipality m ...

51. Persisting a List of Integers with JPA?    stackoverflow.com

We have a pojo that needs to have a list of integers. As an example, I've created a Message pojo and would like to associate a list of groupIds (these ids ...

52. Making serach on database and Listing results with Hibernate in Java    stackoverflow.com

I am developing swing based application with hibernate in java . And ? want to make search on database , and listing result... Before ? used to JDBC and ResultSetTableModel , and ...

53. How to map EnumSet (or List of Enums) in an entity using JPA2    stackoverflow.com

I have entity Person:


@Entity<br>
@Table(schema="", name="PERSON")<br>
public class Person {<br>
   List`<`PaymentType`>` paymentTypesList;<br>
<br>
//some other fields<br>

//getters and setters and other logic<br>
}


and I have enum PaymentType:
public enum PaymentType {<br>
   FIXED, CO_FINANCED, ...

54. org.hibernate.TransientObjectException during Criteria.list()    stackoverflow.com

I have seen posts all over the internet that talk about how to fix the TransientObjectExceptions during save/update/delete but I am having this problem when calling list on my Criteria. I have ...

55. Java-Hibernate-Newbie: How do I acces the values from this list?    stackoverflow.com

I have this class mapped

@Entity
@Table(name = "USERS")
public class User {
 private long id;
 private String userName;
}
and I make a query:
Query query = session.createQuery("select id, userName, count(userName) from User order by ...

56. Saving order of a List in JPA    stackoverflow.com

I have the following question about JPA: Can I save the order of the elements in a java.util.List? In my application the order in which I put elements in the Lists is ...

57. Is this possible: JPA/Hibernate query with list property in result?    stackoverflow.com

In hibernate I want to run this JPQL / HQL query:

select new org.test.userDTO( u.id, u.name, u.securityRoles)
FROM User u
WHERE u.name = :name
userDTO class:
public class UserDTO {
   private Integer id;
  ...

58. Why does this Grails/HQL query with a JOIN return Lists of pairs of domain classes?    stackoverflow.com

I'm having trouble figuring out how to do a "join" in Groovy/Grails and the return values I get

person = User.get(user.id)
def latestPhotosForUser = PhotoOwner.findAll("FROM PhotoOwner AS a, PhotoStorage AS b WHERE (a.owner=:person ...

59. Select an entity according to a list of associated entities    stackoverflow.com

I have the following database schema : Two tables, books and tags, with n-m relationship. Books - Tags We can have for example the book 1, with tags {A,B,C}, and book 2, with tags ...

60. Refreshing a JPA result list which is bound with a jTable    stackoverflow.com

First off, I hage to write this on my mobile. But I'll try to format it properly. In Netbeans I created a jTable and bound it's values to a JPA result set. ...

61. JPQL IN clause: Java-Arrays (or Lists, Sets...)?    stackoverflow.com

I would like to load all objects that have a textual tag set to any of a small but arbitrary number of values from our database. The logical way to go ...

62. Non-empty list with null elements returned from Hibernate query    stackoverflow.com

I'm new to hibernate so not sure if this is an expected behaviour, anyway:

Session session = (Session)entityManager.getDelegate();
Criteria criteria = session.createCriteria(myRequest.class);
criteria.add(Restrictions.eq("username", username));
criteria.setProjection(Projections.max("accesscount"));
List<myRequest> results = criteria.list();
The returned results is a non-empty list with ...

63. Hibernate Query for a List of Objects that matches a List of Objects' ids    stackoverflow.com

Given a classes Foo, Bar which have hibernate mappings to tables Foo, A, B and C

public class Foo {
  Integer aid;
  Integer bid;
  Integer cid;
  ...;
}

public class ...

64. JPQL: What kind of objects contains a result list when querying multiple columns?    stackoverflow.com

I'm trying to do something which is easy as pie in PHP & Co: SELECT COUNT(x) as numItems, AVG(y) as average, ... FROM Z In PHP I would get a simple array like ...

65. how to use a list containing the query result with hibernate and display it in jsp    stackoverflow.com

In my servlet I construct the query like the following:

    net.sf.hibernate.Session s = null;
    net.sf.hibernate.Transaction tx;
    try {
     ...

66. How to retrieve the ordered list of best articles having a minimum number of votes by using HQL?    stackoverflow.com

I have a Vote domain class from my grails application containing properties like article_id and note I want to HQL query the Vote domain class in order to retrieve the 5 best ...

67. How to order by list Index in HQL query?    stackoverflow.com

This is situation I have:
I have two entities with one-to-many relationship mapped like that (only relevant parts are given):

    <class name="xyz.Survey">
        ...

68. How to express "where value is in dynamic list" in HQL/GORM?    stackoverflow.com

For a grails application, I need to find a list of objects whose "attr" is one in a dynamic list of strings. The actual HQL query is more complex, but the ...

69. Hibernate - Restriction for class in a list    stackoverflow.com

I'm trying to pull back a list of items that have a specific type of item in a set. For example:

<class name="Owner" table="OWNER">
<id name="id" column="OWNER_ID" />
<set name="cats" table="OWNER_CATS" lazy="false">
   ...

70. list-index hibernate?    stackoverflow.com

I am bit confusion of list index type,my mapping file has like below <list name="transactionItems" cascade="save-update,delete-orphan" lazy="false"> <key column="TRANSACTION_ID" /> <list-index column="IDX" /> <one-to-many ...

71. How to get a list of the columns (in order) in a database table using a Hibernate session?    stackoverflow.com

I need to retrieve a list of the columns in a table in the order in which they appear. Is this possible using Hibernate? I've got a Hibernate session object, and ...

72. Using EhCache for session.createCriteria(...).list()    stackoverflow.com

I'm benchmarking the performance gains from using a 2nd level cache in Hibernate (enabling EhCache), but it doesn't seem to improve performance. In fact, the time to perform the query slightly ...

73. Hibernate custom SQL query with join - avoiding returning a list of arrays    stackoverflow.com

I have a custom SQL query in Hibernate (3.5.2) in which I want to return a mapped object, and an associated (joined) object. However, Hibernate seems to be giving me a ...

74. Returning a list from a ManyToMany relationship?    stackoverflow.com

I have two tables: Users and Roles. A user may have more roles, so this is a ManyToMany relationship. I've generated the entity classes with Netbeans, and they look like this:

@Table(name = ...

75. Using Hibernate to persist a one-to-many list with a superclass type    stackoverflow.com

Somebody asked this question on the Hibernate forums and I'm linking to it here because I have the same question. Nobody seemed to be of any help there so I'm ...

76. How to select a partial object including a list with new() syntax in Hibernate    stackoverflow.com

In my Hibernated system, I have a class Picture that has some simple data, a list of Installations and some (huge) binary data. The list of Installations is implemented with a ...

77. List Hibernate configuration parametrs    stackoverflow.com

Is there a way to programatically get Hibernate configuration parameter values, if I have access to a SessionFactory object? I would like to list the configuration in a GUI view, for debuging ...

78. Hiberante property type list, add it through sql to table    stackoverflow.com

I recently added new property in one class, its list property and I have written xml mapping for that property,due to few reasons I am not suppose to delete database or ...

79. Hibernate Criteria: inheritence: Get a list of only the root class entities    stackoverflow.com

Assume i have:

@Inheritance(strategy = InheritanceType.JOINED)
public class Child extends Parent{
}
How can i do a selection of only the instances saved as a Parent, not as a Child. Thank you

80. How do i transform a HQL result to List where T is a mapped class    stackoverflow.com

I have this nhibernate query:

var q =
               NHibernateSession.Current.CreateSQLQuery
          ...

81. Hibernate sticking NULL values into list    stackoverflow.com

I have inherited a bit of Java code that uses Hibernate. Some of the people using this code are now reporting that they are getting NullPointerExceptions all over the place. ...

82. Filter list contained in entity returned by jpa/hibernate query    stackoverflow.com

I have a simple jpa entity 'ApplicationForm' with a one to many list in it:

 @OneToMany(cascade=CascadeType.REMOVE, mappedBy="textQuestion")
 private List<Dictionary> questions;
The variable Dictionary contained in ApplicationForm is just another plain entity with ...

83. How do I sort a linked list in hql?    stackoverflow.com

Same question as this, only I'd like to do it in Hibernate (using grails if that matters). So the domain class looks like this

class LinkedElement {
  LinkedElement precedingElement
  String ...

84. Struts2 Hibernate (returning a list causing hibernate to fetch data from all relationships)    stackoverflow.com

I am creating dependent drop downs using Struts2 jquery. The problem is that getLobList() method inside action class is causing hibernate to fetch all data for a lob. If I remove ...

85. NHibernate HQL join query for list of entities returning duplicates    stackoverflow.com

I am attempting to query entities with HQL in order to return a list of objects. The query returns the correct number of rows, but the first entry (ie the first ...

86. eclipselink doesn't fetch list    stackoverflow.com

there are two entity classes:

@Entity
public class Place implements Serializable {
    @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id;
    @OneToMany(mappedBy = "place")
    private List<Event> ...

87. Hibernate: Retrieving Lists    stackoverflow.com

I am a beginner with hibernate. My intetions are really simple: I have mapped objects into one table with annotations. Now I want to retrieve them as a List of objects ...

88. Using CF9 ORM for listing pages: HQL or SQL?    stackoverflow.com

I have an ORM mapping which has: magazine object with a many-to-one relationship to a genre and a one-to-many relationship to issues I have an admin page which displays a listing of basic magazine info, ...

89. JPA/toplink heterogeneous list of entities    stackoverflow.com

Colleagues, Using JPA I need resolve following issue: at database level exits 3 entities (saying SuperEntity, DetailsAEntity and DetailsBEntity). SuperEntity contains common part of fields for DetailsAEntity and DetailsBEntity. So the question: is ...

90. Hibernate: cant get the associated List retrieved    stackoverflow.com

An entity X has a list of entity Y and the entity Y has an instance of entity Z. The relation between X to Y is OneToMany and the relation between Y ...

91. Hibernate one to many mapping works with a list but not a set?    stackoverflow.com

Sorry to bother - perhaps this is a very simple question - but for some reason the version below fails to get parsed, whereas the version with set works fine. In ...

92. JPA Fetch Join Filter on List/Set    stackoverflow.com

I'm having problem on JPA (Hibernate) Fetch Join : Here is my JPQL query SELECT n FROM News n LEFT JOIN FETCH n.profiles AS pr WHERE pr.id=?1 But it's not working. How ...

93. hibernate query.list() method is returning empty list instead of null value    stackoverflow.com

When there are no rows, both query.list() and criteria.list() are returning empty list instead of a null value. What is the reason behind this?

94. Using JPA2 criteria API without Metamodel on a List property    stackoverflow.com

How can I formulate the following JPA2 criteria query without using the metamodel classes:

    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<Employee> cq = cb.createQuery(Employee.class);
    ...

95. JPA/Hibernate mapping dynamic columns as a List of objects    stackoverflow.com

I have an existing DB schema which I'm trying to ORM'ise with JPA/Hibernate annotations. The schema is designed to allow for clients to assoicate extra information with each row in a table. ...

96. Problem in saving List through JPA?    stackoverflow.com

I have already seen http://stackoverflow.com/questions/287201/how-to-persist-a-property-of-type-liststringin-jpa and http://stackoverflow.com/questions/796347/map-a-list-of-strings-with-jpa-hibernate-annotations ============================================================================= I am trying to save

List<String>
through JPA. I came to know that JPA 1.0 doesn't have any way to persist collection of non-entity classes ...

97. Hibernate/JPA + Derby - SELECT statement has too many items in GROUP BY, ORDER BY or select list    stackoverflow.com

I use Hibernate for JPA DB mapping with Derby DB. For a complex object structure I am getting "org.apache.derby.client.am.SqlException: SELECT statement has too many items in GROUP BY, ORDER BY or ...

98. How to make this tutorial work? Could not determine type for: java.util.List, at table: College, for columns    stackoverflow.com

Now, i am learning hibernate, and started to using it in my project. It is a CRUD application. I used hibernate for all the crud operations. It works for all of them. ...

99. JPA: Can I force objects to be persisted to the database in the order that the objects were sent to persist()?    stackoverflow.com

I am creating a billing system which manages a Ledger for each customer. Each Ledger has a list of LedgerEntry's which records each customer transaction. As I was testing this, ...

100. Hibernate: How to persist Class that contains Map>    stackoverflow.com

I want to persist the following class, including 'bar'

Class Foo
{
  Map<String, List<String>> bar;
  // ...
  // other stuff.....
}
How do I do this in Hibernate? If possible, how to do ...