attribute 1 « Map « JPA Q&A

1. problem with basic attributes java.sql.Blob

I have this code

@Table(name = "picture")
public class Picture implements Serializable {
    @Column(name = "id")
    private int ...

2. Java Frameworks that support Entity-Attribute-Value Models

I am interested in developing a portal-based application that works with EAV models and would like to know if there are any Java frameworks that aid in this type ...

3. Running hibernate tool annotation generation without the "catalog" attribute

when i run my hibernate tools it reads from the db and create java classes for each tables, and a java class for composite primary keys. that's great. the problem is this line


4. Find by Object Attributes in JPA

i was wondering whether it is possible to find an object using an example object like you can in hibernate with:

Cat cat = new Cat();
cat.Sex = 'F';
cat.Color = Color.Black;
List results = ...

5. Java Persistence API(JPA) - Overriding MappedSuperClass's attributes

I have the following questions

  1. I have the '@Id' annotated field as part of my '@MappedSuperClass' and I am letting all my entities extend the MappedSuperClass.Now,how do I override the super class ...

6. Attributes on Many-to-Many relationships (Hibernate)

I have entity classes A and C. They are mapping the tables tblA and tblC and have a many-to-many relationship between them, with tblB to map between them. tblB contains A_ID, ...

7. Hibernate Criteria - Exclude records with same id but different attribute values

I'm trying to find records where status = "a" for a Person but exclude records where the same person has another record with a status="b" SELECT * FROM Person WHERE STATUS ...

8. Hibernate Inheritance Mapping and Attribute Override

The system I'm working on has a domain object named Order which inherits from AbstractPersistentObject. Now I need to add another domain object named ExternalOrder which has some of the properties ...

9. Hibernate entity with user defined attributes

Can someone please give me some tips on modeling hibernate entities that have some known attributes while the majority are defined by the user of the system (during initial setup of ...

10. Is there any way to state that a field of an entity class is not a persistent attribute?

The question is in the title. Some explanation: I can't implement necessary mapping. But I can get all necessary data using queries in DAOs. So, I want to insert that data manually ...

11. Hibernate Query that Orders an Attribute based on a nested path

I have two Objects, Entries and Samples. Each entry has an associated set of Samples, and each Sample has a vote associated with it. I need to query the ...

12. How to write select queries for paginating output from ManyToMany attributes

I have a Group table with ManyToMany relationship with the User table via a join table. A Group could contain a lot of users or could contain sub groups containing more ...

13. Hibernate Reference column in table to indicate how to unmarshall an attribute in a different column in the same table

I have an entity that I want to persist through Hibernate (3.2) The EntityBean has a column that indicates how another value of the entity bean should be unmarshalled:

<class name="ServiceAttributeValue" table="service_attribute_value">

14. Hibernate Annotation + AspectJ -> Attributes names pbs in HQL

I'm looking for a way to use aspects to inject parameters in hibernate annotated classes. Here is a user :

 public class User implements IHasCity {


15. use of insert and update attributes

What is the use of insert and update attribute in property tag in hibernate ?

16. Hibernate: Querying objects by attributes of inherited classes

I ran into a problem with Hibernate concerning queries on classes which use inheritance. Basically I've the following class hierarchy:

@Table( name = "recording" ) 
class Recording 
{    ...

17. Error in Netbeans(?): attribute column name (length) is a reserved Java Persistence QL keyword

I have a column named length in an Oracle database. I cannot change the column name. When I use the @Column(name="length") in a JPA Entity I get the following error: ...

18. Hibernate: Dirty Checking and Only Update of Dirty Attributes?

in "good old JDBC days" I wrote a lot of SQL Queries that did very targeted updates of only the "attributes/members" that were actually changed: For Example having an object with ...

19. Null transient attributes

I have a method annotated with @PrePersist annotation but I've seen that when this method is executed all my transient attributes (the attributes with the @Transient annotation) are null. When I ...

20. Why Hibernates ignores the name attribute of the @Column annotation?

Using Hibernate 3.3.1 and Hibernate Annotations 3.4, the database is DB2/400 V6R1, running that on WebSphere I have the following class

public class Ciinvhd implements Serializable {


21. What does the length attribute do when set on the @Column JPA annontation?

What exactly does setting the length on a column do in JPA?

@Column(name = "middle_name", nullable = false, length = 32)
public String getMiddleName() {
    return this.middleName;
I understand that you ...

22. How to set up precision attribute used by @Collumn annotation?

I often use java.lang.Integer as primary key. Here you can see some piece of code

private class Person {

    private Integer id;


23. Hibernate entities stored as HttpSession attribute values

I'm dealing with a legacy Java application with a large, fairly messy codebase. There's a fairly standard 'User' object that gets stored in the HttpSession between requests, so the servlets ...

24. Modelling a manyToMany relationship with attributes

I have a ManyToMany relationship between two classes, for instance class Customer and class Item. A customer can buy several items and an item can be bought by different customers. I ...

25. How do I insert the null value in a Boolean attribute when using Hibernate?

I have a class with a Boolean attribute. When I instantiate and persist this class, the Boolean attribute is stored with the "false" value instead of the expectable "null". How can ...

26. Modifying annotation attribute value at runtime in java

some methods in our model pojos have been annotated like this:

@Column(name="cli_clipping_id", updatable=false, columnDefinition = "varchar(" + ModelUtils.ID_LENGTH + ") COLLATE utf8_bin")
columnDefinition attribute is database vendor dependant, so when trying to drop ...

27. Superkey consists of three attributes - how to cope with Hibernate?

Consider a relation with a candidate key of three attributes: alt text I was wondering if someone could give me an example of a config file for Hibernate?

28. Hibernate+Oracle+Clob: Content of attributes get switched

Has anyone heard of this error before: I have a Java 5 application, that uses Hibernate 3.3.2 to access an Oracle Database 10g, the JDBC driver is the Oracle light driver version ...

29. Why the compiler doesn't recognize the metamodel attributes?

Is the criteria api of eclipselink jpa2 supported for java se 6 projects? If not, that's my problem. Do I need to specify anything special to the criteria api in the persistence.xml? This ...

30. What does 'length' attribute in hibernate mapping file do

I read that 'length' attribute in hibernate mapping file for a table column is optional. Does it truncate data while inserting into database if length exceeds the column length? Thanks Nayn

31. EJB3/JPA entity with an aggregated attribute

I wanted to know if there is a way to get in a One2Many relationship a field of the One side that is an aggregate of the Many side. Let's take the ...

32. JPA/Hibernate Static Metamodel Attributes not Populated -- NullPointerException

I would like to use JPA2 Criteria API with metamodel objects, which seems to be pretty easy:

Root<JPAAlbum> albm = cq.from(JPAAlbum.class);
... albm.get(JPAAlbum_.theme) ... ;
but this Root.get always throws a NullPointerException. JPAAlbum_.theme was ...

33. Why cannot a JPA mapping attribute be a LinkedHashset?

Motivated by this question, I've tried to change the following:

 @ManyToMany(cascade={CascadeType.REMOVE, CascadeType.MERGE})
private Set<Expression> exps = new LinkedHashSet<Expression>();
 @ManyToMany(cascade={CascadeType.REMOVE, CascadeType.MERGE})
    private LinkedHashSet<Expression> exps = new LinkedHashSet<Expression>();
However, such a ...

34. GORM Querying where filter is not a direct attribute of a class

I am trying to figure out the most efficient / effective way of performing a certain type of query using Grails GORM. This is the scenario where I want to query ...

35. How can I manage to create a many-to-many relationship. The generated entity will have extra attributes

I have 2 entities: Class(of students) and Student. A student can be in many classes(like in college) and a class has many students. The problem is how to ensure that this ...

36. How to index attributes from associations?

When I'm indexing objects in my application (using hibernate search and lucene) I would like to store in the index some of the attributes of the object's associations. I need to ...

37. JPA: directly mapping collection size to attribute using count?

A has a one-to-many relationship to B. Hence, class A has an attribute collectionOfB. Is there any way I could map "count B" to single attribute in A? The purpose would be to ...

38. JPA: createNativeQuery.getSingleResult() return an object, how I can get the value of one attribute inside that object

I have a query like this

SET @rownum := 0; 
SELECT rank, id, point FROM
      SELECT @rownum := @rownum + 1 ...

39. Hibernate - Envers -> auditing / versioning of an attribute, but only if the value changed

I have a problem with Hibernate - Envers. I have a domain object with only one audited attribute status which can be one of the numbers 0,1,2,3,4,5.

public class Item {

40. Make use of Hibernate attribute mapping in plain SQL query

Is there any way to let Hibernate replace entity attribute names in a native SQL query (created by Session.createSQLQuery())? I would like to build a query where arbitrary columns are fetched which ...

41. Hibernate many-to-many relationship using non-identifier attribute for join column

Is it possible to create a many-to-many relationship in Hibernate using annotations if one of the join columns is not the identifier attribute for that entity? The parent entity has two ...

42. Using Hibernate annotations to persist custom value for Enumerated attribute

I have lots of Java enums that I persist with Hibernate. As far as I know there are two different standard ways to persist these enums:

This is the default, and it ...

43. Hibernate : How override an attribute from mapped super class

The generic entity, super class:

public abstract class GenericEntity {
    private Integer id;
    public Integer getId() {return id;}
    public void setId(Integer id) { ...

44. Hibernate inheritance, Collections and @OrderedBy superclass attribute generates MySQL syntax Error

I' using Hibernate 3.6.1 to map three entities

@Inheritance(strategy = InheritanceType.JOINED)
public class Entry {
   private Long id; 
   private Date publishedAt; 


45. ClassCastException when selecting entity with specific attributes

I want to select an entity with specific attributes. Retrieving the whole entity is not an option because of the file attribute which returns a byte[] which would slow down the ...

46. HQL: Finding object where child objects include specific attribute values

This is an extension of this question. Instead of SQL, how would I do the same using HQL? (i.e. find all dogs that have both the colors of black and white ...

47. Problem with Date format using an attribute Calendar with JPA

I've a problem using an attribute Calendar with JPA:

@Column(name = "Date")
private Calendar date;
By default it is setted as mm/dd/yyyy and I need it in dd/mm/yyyy, can anyone help me? I've seen that is ...

48. How to map an association table that carries some attributes

im using hibernate xml to map my databse, but i didn't knew how to map a many to many relation (STUDENT,COURSE,TEACHER) that have an association table(Student_Course_Teacher) ,this table carries the ...

49. JPA 2.0 Metamodel: How to retrieve attributes corresponding to a UniqueConstraint annotation

I have a bunch of entities that have a surrogate primary key and one or more business keys. The columns containing the business keys are available as an UniqueConstraint annotation on ...

50. Making attributes in my persistent model unique

In the play framework on my models how can I make a certain field a key, as in it must be unique and not repeated. I am using JPA/Hibernate. For instance ...

51. MySQL condition in where-clause of a JPA named query with nullable attribute as parameter

How can a condition be specified in a where-clause of a JPA named query for a MySQL 5.1 database, in case some of the attributes which are passed as parameter are ...

52. Grails, attribute in the relationship (join table)

With grails how can I make an attribute on a relation in the join table. like: Class A in relation with Class B as a role X. Class A in relation with ...

53. JPA: flexibly mapping "attributes" (key/value data of various data types) to an entity

I'm having some issues deciding how to map key/value data to an entity in a sensible and performant way. I might even be taking a wrong approach here, so I'm thankful ...

54. Inject attribute into JPQL SELECT clause

Let's depict the following use case: I have a JPQL Query which on the fly creates data objects using the new keyword. In the SELECT clause I would like to inject ...

55. How to redefine an attribute in inherited classes in JPA

I have a generic Database structure which can store several user-defined records. For example, the main table is RECORD and the columns are STRING01, STRING02, [...], NUM01, NUM02 etc. I know this ...

56. Hibernate mapping-resource must be followed by either attribute specifications, ">" or "/>".'

I have a problem with mapping-resource in my hibernate.cfg.xml - I get

Element type "mapping-resource" must be followed by either attribute specifications, ">" or "/>".'
my hibernate.cfg.xml looks like
<?xml version='1.0' encoding='utf-8'?>

57. Hibernate: Unable to resolve attribute against path for a very simple object hierarchy

Anyone have any ideas why hibernate v3.6.7 has problems with the seemingly simple class hierarchy below?

public class X implements Serializable {
    String id;


58. Accessing custom attributes in a hibernate mapping

Say I wanted to add custom attributes to the hibernate mapping xml document (they would probably be namespaced). Does hibernate provide any way to access these via the meta-model (e.g. ...

59. Adding attributes to hibernate mapping file

If I decorate the hibernate mapping xml file with additional attributes of my own is there a way to access these via the hibernate meta-model or would I have to access ...

60. 2 attributes in a table mapped by a reference table's attribute

I need your help please. I'm trying to map my objects with hibernate and jpa. I have 2 tables , reference and person ( for example)

      the attributs ...

61. JPA root get in Hibernate not working with IdClass attribute

I'm trying to do a multiselect on an entity with an IdClass. I can't get a column that is mapped as part of the ID. It's clear why I can't, as ...

62. JPA updatable attribute and JPQL

I have made a couple of observations in my test and I am finding them hard to understand. My tests perform some basic update (or merge) operations on an Entity which ...

63. Retrieving parent element by distant related collection's attribute in HQL?

Good morning, everyone. I need some query help. You can assume I understand relatively complex SQL queries, but this newfangled HQL thing is confusing me a little. I have 5 objects, A ...

64. How to set extra attribute for table in hibernate reverse engineering?

I have the following hibernate.reveng.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "" >

  <table-filter match-schema="public" match-name="system_access"/>
I would like to make the SystemAccess table mutable="false" and <cache usage="read-only" ...

65. Hibernate Single_Table persistence The entity has no primary key attribute defined on subclass

Good evening. I'm trying to map a class hierarchy to a single table using JPA/Hibernate and receive an error on my subclass stating "The entity has no primary key attribute defined". ...

66. compare two EntityManagerFactories for having PersistenceUnits with identical connection attributes

Having two JPA2 (EclipseLink) EntityManagerFactory instances what would be the best way to detect that their PersistenceUnit attributes are identical?

67. When should I favor JOIN instead of attribute access in singular attributes?

Consider the following Entity:

public class Employee {

    private Long id;

    private String name;

    // ...

68. Using Hibernate with a map for the attributes of a table

So I have some code that represents a songs metadata, instead of having getters and setters for each field I put the values in map, each field is a String, and ...

69. JPA: Override a property attribute in a subclass

Hi, I have a subclass of a JPA entity, superclass that I cannot modify, but I need to mark some fields (in the subclass) with: @Column(updatable = false, insertable = false) ...

70. IllegalAccessException and IllegalArgumentException when processing a Hibernate HQL Query with Select "table.attribute" from Table table

I have the problem that I can't query the values of an database table attribute in HQL. Every time I get a Result like this: Bytes Bytes Bytes Bytes Chars Chars B@132689f B@8c1d87 B@107ebfc B@487553 B@288f98 B@c2c01f . . . Additionally I get the following Exceptions: IllegalAccessException: Class org.netbeans.modules.hibernate.hqleditor.ui.HQLEditorTopComponent can not access a member of class java.lang.String with modifiers "" IllegalArgumentException ...

71. hibernate "set" element "name" attribute

The documentation says I can use the name attribute in a set, but when using the DTD provided, my xml parser doesn't allow me to make a set like this: it says "set" needs an attribute called "role" but the documentation has this example:

72. Hibernate/XDoclet changing name attribute to role

Has anyone ever come across an issue where XDoclet generates the Hibernate mapping of a "bag" and changes the attribute "name" to show up in the mapping file as "role" instead. For some reason, we have one class that this happens to, and therefore when you deploy it, it fails because the mandatory name attribute is not there. Here is the ...

73. JPA many-to-many with extra attribute

Hi, I have this tables: Table: users id integer name varchar Table: user_contacts user_id integer contact_id integer active boolean This is a self many-to-many relationship (user_id and contact_id is an user) with an extra attribute. How I can map this with JPA? With hibernate I do this:

74. ManyToMany with extra attribute in JPA

I'm making a manyToMany relation between two objects, in JPA, and I want to add an extra property on the relation. I've been following the example found at: ManyToMay Example This works fine, but: 1. The relation table in DB will get two id columns for each object, one as primary key and one for the foreign key (=four id columns ...

75. JPQL: refering to inherited attribute.

I have following entities: @Entity Inheritance type is JOINED. class E{ String name; } @Entity class EA extends E{ int number; } @Entity class EB extends EA{ long value; } @Entity class EC extends EB{ .... } In the JPQL is there a way to refer to the inherited attribute with out knowing the exact subclass ? (ec.super.value or I ...

76. Hibernate : generated attribute of the property element

Hi, I am started reading hibernate. In one of my examples,I mentioned the "generated" attribute of the "property" element as generated="always" as per the hibernate documentation and some other book. But getting the below parser error. public class Student { private Long id; private String name; private int age; private Date updated; // getters and setters } Mapping : ...

77. Hibernate: confusion how to include seperate attribute in many-to-many mapping file

Hello, I am stuck in the following scenario TABLES: Vehicle(vid, vdesc, basePrice, vFeatures), Feature(fid, fcode, fprice), VehicleFeatures(vid, fid, featurePrice) Here I have associated Vechicle-Feature by many-to-many relationship. I am also storing the price of a particular feature for a particular vehicle in VehicleFeatures table. I would like to know is this correct way to map association between Vehicle and Feature or ...

78. Hibernate Unique Key attribute

Hi, I have a table with name and id. Id is primary key and auto incremented. I am using hibernate 3.2 and in my mapping file i have specified unique="true" in the property for name column. But still I am able to add same name more than once. I predict my code should throw some exception when i try to add ...

79. how to retrieve hibernate parent class attribute from displaytag tag?

hai any one say how to refer parent table of hibernate class attribute using display tag property .. my hibernate child pojo class contains variable name as parent class in hibernate (parent table ) name (MaterialRequest )... child class contains variable example : private MaterialRequest materialrequest; child class name MaterialRequestItems; how to get attribute from MaterialRequest in display tag property javascript:emoticon(':censored:'); ...

81. JPA Many to Many relationship with attribute to self

Hi Karsten. Well, I am not cutting and pasting my requirements and asking people to do my job. Sorry if youve thought I was doing this. From this site - - there is an example, so it seems I cant use @ManyToMany directly. Instead, I am using two 1:N relationships The problem is that the relationship is a self join, ...

83. Hibernate Cascade attribute

cascade is used when an item in table A relies on an item in Table B (ie has a foreign key reference) and the data in table A has no meaning if the item in Table B is deleted. eg A Person has an Address, the Address contains the ID of the Person. If a Person is deleted then the delete ...

84. JPA: how to map context-dependent attributes ?

I have a domain entity "A" which has an attribute "value"; "value" is of (interface) type "Value", holding some BigDecimal quantity. "Value" in my domain gets implemented by, say, some custom classes, for instance "Money", "Percent" and so on, with each having a constructor that has a different set of parameters. At time of reading an instance of "A" from the ...

85. JPA-IntermittentThe attribute [] of class [] is mapped to a primary column

Further observations - changing the name of the Order bean to Wrapper makes the problem go away (Order bean is actually not used at all in the test) - Removing the Order bean makes the problem go away - Removing the query (2.2) makes the problem go away - Have the issue both on jdk 1.5 and 1.6 - Have the ...

86. Legacy Database with split Attribute

Hi I have a legacy database where lots of columns contain fine granular data like i.e. a telephone number split into 12 different columns. I was wondering if there is any trick to map these columns into a single primitive Attribute containing the whole number. In some cases these primitives are even mapped to different tables. So my question: Is there ...

87. many-to-one returned objects' attributes are null - why?

Newbie Joined: Thu Feb 02, 2006 8:45 am Posts: 4 Location: Boston Hi. I have some experience with Hibernate, and have it all basically working (with a recent hibernate version), i.e. returning simple object-relation mappings, but my new many-to-one mappings are not working, and I don't understand why. Looking over my books and tutorials and such, they look ok to me. ...

88. m:n mapping and attributes in the mapping table

Hello, i am in the situation that i have an m:n relationship between two entities. I know, if i want to have mapping attributes i should spezify an mapping table entity where i can places these and make an m:1 <-> mapping-table <-> 1:n relation instead. But what is when an application is grown with an m:n relation, and then you ...

89. confusion:Add additional attribute in many-to-many mapping

Hello, I am stuck in the following scenario TABLES: Vehicle(vid, vdesc, basePrice, vFeatures), Feature(fid, fcode, fprice), VehicleFeatures(vid, fid, featurePrice) Here I have associated Vechicle-Feature by many-to-many relationship. I am also storing the price of a particular feature for a particular vehicle in VehicleFeatures table. I would like to know is this correct way to map association between Vehicle and Feature or ...

90. Is it possible to map attributes to custom resolvers?

Maybe it is the wrong place to make this question, and I know it has to be a really basic hibernate question, well, my problem is that I have a pojo like this one: class Pojo { Integer id; TypeA foo; TypeB zas; ... getters and setters.... } class TypeA { Integer id; String description; ... getters and setters.... } class ...

93. How to find out which attribute is used as PK

Hi all, is there any way how to find out which attribute of hibernate mapped class is used as primary key ? e.g in this case primary key is id attribute as I'm using ...

94. mapped attribute

Hello. Let's say i have a database table person : id | first_name | last_name I have a pojo Person : Integer id; String firstName; String lastName Does anyone knows how to annotate a field that does not exist in database that is put in this pojo. Let's say that in this pojo i need to an attribute Date calculatedDate. How ...

95. Attribute/column name "end" has special meaning?

public class OrganizationMembership { .... @Temporal (value = TemporalType.TIMESTAMP) @Column(nullable = false, updatable = true) private Date startDate; @Temporal (value = TemporalType.TIMESTAMP) @Column(nullable = false, updatable = true) private Date end; .... }

96. Fetch all entity's attributes

98. Help ManyToMany with attributes

My friends, I need help. How I can develop it using hibernate annotation ? Code: public class Project(){ private Long id ; } public class Item(){ private Long id ; } Where relationship... Example: Code: class relationship class Project class Item 01/10/2010 ...

99. search by any attribute ?

100. How to order by optional attributes without restricting?

I already tried this, but on the wrong part ;) My case is a m:n relationship with A:N, N:M, M:B tables.I put the "left join" on the M:N object. Your posting encouraged me to try it again and I found the solution in putting the "left join" on the M:B relation ;) Thank you.