attribute 4 « Map « JPA Q&A





1. compiling with the -Xlint:unchecked attribute    forum.hibernate.org

HI there, When I compile my project using ANT the compiler states the following: compile: [javac] Compiling 2 source files to C:\Scholastic_Hibernate\build\classes [javac] Note: C:\Scholastic_Hibernate\src\java\scholastic\models\Company.jav a uses unchecked or unsafe operations. [javac] Note: Recompile with -Xlint:unchecked for details. My build.xml file has the following: Is there an ...

2. Bug since 3.2.2 when selecting many-to-one attribute    forum.hibernate.org

Hello, I suspect a (major) bug here, there is wrong behaviour that occurs since version 3.2.2 and has never occurred with older versions (3.2.1, 3.1, 3.0, 2.x). Hibernate version: 3.2.2 Mapping documents: (the mapping is only a partial example) When I execute HQL "select c.segment from Customer c", ...

3. How to reset a value of a attribute(column) of a row?    forum.hibernate.org

Hi I have a basic question(being newbie to hibernate) I use hibernate to load Objects from Database. Once I load the object with let's say 10 attributes, how do I reset the value of few of those attributes? If I call the setter method and pass null, that works but when I commit, the actual values in the database are not ...

5. Get attribute from join table    forum.hibernate.org

6. many-to-one not-found attribute not working    forum.hibernate.org

7. About Hibernate Category Attribute    forum.hibernate.org

9. How to use java.util.Map as Entity attribute? [Solved]    forum.hibernate.org

I've found the source of problem: I've forgot to use @CollectionOfElements annotation. So the correct source is: @Entity public class Sport implements Serializable { //... private Map nameMap = new HashMap(); //... @CollectionOfElements public Map getNameMap() { return nameMap; } public String getName(String lang){ return nameMap.get(lang); } public void setNameMap(Map nameMap) { this.nameMap = nameMap; } public ...





11. ClassCastException occurs using Set elements sort attribute.    forum.hibernate.org

Hello, I have strange problem occuring when executing one of my test class in my project. This is the snippet of Set mapping i am doing in my hibernate mapping file for Category1Category2.java model

17. [Mapping]How to have an attribute referecing another DB ?    forum.hibernate.org

Hi, hi have a DB which contains a USER table, allowing to determine which Hibernate session (linked to anoter DB) to use for the connected user. The problem is that some tables of these anoter DB are referencing the obejct USER. Is that possible to configure the mapping files so that the "user" attirbute references another DB ? My mapping : ...

18. Formula Attribute    forum.hibernate.org

Before inserting card number into database, I need to perform encryption using below formula. In Mapping I did like below In the bean Creditcard cardobj = new Creditcard(); cardobj.setCard_type("VISA"); cardobj.setCard_number("234509873333"); It is inserting null value. Please suggest me where I am doing mistake. Thanks in Advance

19. Missing column when doing insert with formula attribute    forum.hibernate.org

Newbie Joined: Mon Jun 25, 2007 3:43 am Posts: 1 Background: Our application uses a "subclass-per-table"-hierarchy. The superclass, called LogRecords, holds a discriminator column. The application consists of two, standalone, parts: one which logs data to the database and one which reads data from the database. The reading part may use a different version of the mapping files than the logging ...

20. Once again: Many-to-many with attribute ... still painful?    forum.hibernate.org

Hello. Over a year ago I wrote about how to map a many-to-many relationship that had an attribute in the link table. It was a painful experience. I wound up doing it all by hand. XDoclet wouldn't generate my tables correctly so I hand-hacked my mapping files. And I couldn't find a way to tell Hibernate to deal with the attribute ...

21. "mutable" attribute ignored when using 2ndLevelCac    forum.hibernate.org

Hello, many entities in my application are read-only, so I use the mutable="false" setting in their mapping files. This causes Hibernate to set their status to read-only and omit the snapshot creation (TwoPhaseLoad, lines 172-178). This read-only status in turn optimizes flushing performance since the PersistenceContext's "hasNonReadOnlyEntities" flag is false when only read-only entities are in a session, causing flushing attempts ...

22. non-primary-key attribute 'id' mapped to primary-key    forum.hibernate.org

Hi! I got an entity which has a non-primary-key attribute named 'id' (I know that's a crap, but can't change this). The primary key id is named 'guid'. Whenever I use a query I'm searching for the attribute 'id', e.g. Code: from TestUser u where u.id=:id and u.name=:name; the parameter 'id' is not mapped to 'id' but to 'guid' (see generated ...

24. The mapping attribute parent="xxx" doesn't work    forum.hibernate.org

The mapping attribute parent="xxx" doesn't work Hibernate Version: version 3.2.5 Code: ...

25. One-to-one with outside attribute?    forum.hibernate.org

26. How to add attribute (ie. hardOneToOne=true) to @OneToOne    forum.hibernate.org

Folks, I would like to extend the behavior of @OneToOne I want to add an attribute to the annotation. Is that code extensible enough for me to do this? Implementing my desaign off of existing attributes mutes out original and itnended behavior of the annotation itself. In order for me to properly segregate the outcome, I would like to extend the ...

27. entities order by dynamic attribute    forum.hibernate.org

Hello, I use a dynamic-map-entity which has a map of attributes stored in a second table. Accessing the entities works fine with an own tupelizer. Now I want to use queries with "order by" on the dynamic attributes. I tried this, but it does not work: String query = "FROM " + entity + " AS entity" + " JOIN entity.attributes ...

29. Lazy Attribute    forum.hibernate.org

30. how to map max() value as attribute    forum.hibernate.org

...

31. Type of attribute    forum.hibernate.org

Hello, I use to group multiple properties to define a logical key for a multi-column unique constraint in a . Code: ...

32. HQL : how to update attribute of derived class?    forum.hibernate.org

String sql = "update B set quantity = :newQuanity where oid = :oid"; Query query = session.createQuery(sql); query.setString("oid", a.getOid()); query.setLong("newQuanity", quanity); ...

33. Can i get all dirty attributes ?    forum.hibernate.org

34. How the cascade attribute shall be set?    forum.hibernate.org

I have various one-to-many situations where parent/child update have different requirements and I currently only use the parent object merge for all changes on parent and child. 1) update on parent without any change on its childred. Shall I set cascade="delete-orphan"? 2) update on one child. Shall I set cascade="merge"? 3) add one child. cascade="save-update"? 4) delete one child. cascade="save-update"? Shall ...

35. Mapping a class without an id attribute    forum.hibernate.org

37. Question about "version" attribute names in MySQL    forum.hibernate.org

It's definitely not a bug. Just because "version" has special meaning in hibernate( to control concurrency ). I don't know what tool you use to "produced" the mapping file but, I think it mistakenly treat that version property as version. Just like if you have a id property, it will by default be treated as id. That's why I prefer hand ...

38. Use of map-type attribute in queries    forum.hibernate.org

More exact, these are my classes: @Entity @Indexed public class Ficha { @Id @DocumentId private Integer id; @IndexedEmbeded private Translation translatedName; @IndexedEmbeded private Translation translatedDescription; .... ... @Entity @Indexed public class Translation { @Id @DocumentId private Integer id; @IndexedEmbeded Map translationValues; .... ... @Entity @Indexed public class TranslationValue { @Id @DocumentId private Integer id; @Field(index=Index.TOKENIZED, store=Store.NO) String value; .... ...

39. Map Relationship Attributes to multiple properties    forum.hibernate.org

Hi! I have the following problem where I wanted to map relationship attributes on different properties. The example is situated in the domain of theatre shows. The theatre has several seats and each seat can be sold for a different show. A reseller can then by a contingent of seats for a certain show and assign a price to every seat. ...

40. meaning of discriminator-value attribute of class tag    forum.hibernate.org

Following is a description that is been taken (extract) from Java Persistence book. Credit goes to the authors. I just worded a different similar example. This is a case that I know where it can be used. Suppose we have two (it can be as many as possible) classes (that has some common/general properties) in Java and one table to represent ...

41. Usage of mutable attribute.    forum.hibernate.org

Hi all, We have to deal with a class used by our application in the following way : - read entities - insert new entities - NEVER update entitites - NEVER delete entities Is the usage of the class attribute mutable="false" is appropriate in this case to get some hibernate optimizations (which ones ? ;)) Or is the mutable="false" should only ...

42. @Column attribute validation    forum.hibernate.org

43. Hibernate not Setting Class Attributes    forum.hibernate.org

I have code similar to the code in section 6.1.5 of Java Persistence with Hibernate. This is the case where an owning class (let's call this Class1) uses a Map to store many instances of a second class (let's call this Class2). The objects of both classes are being persisted as I can see the data in Oracle using an external ...

44. insert="false" attribute question    forum.hibernate.org

I have a property mapped like following And in the database the column has not-null constraint and default value as 'Y' But when i do getHibernatetemplate().save(obj), value for that column goes in as null. whereas i expected that column not to be part of insert SQL and would automatically be assigned with the ...

45. Errors with lazt attribute in "select new"    forum.hibernate.org

Newbie Joined: Thu Jun 26, 2008 12:50 am Posts: 8 Hi, We've got a problem where we are using "select new" to create a pojo that contains the results from a query that gathers summary information from the system. The query is simple getting a code and a count of unmatched rows in our DB: Code: final Query peerOrgCodeQuery = em.createQuery( ...

46. Mapping N:M relationship with characterizing attributes    forum.hibernate.org

Hi all I'm new in Hibernate programming and I've a problem defining a N:M relationship with attributes. For example, suppose to have the following data model: CREATE TABLE Concept ( id CHARACTER VARYING(20) NOT NULL, description TEXT, ... PRIMARY KEY(id) ); CREATE TABLE Feature ( id BIGINT NOT NULL, name CHARACTER VARYING(20) NOT NULL, ... PRIMARY KEY(id) ); CREATE TABLE ConceptFeatureRelationship ...

47. One class with attributes coming from different tables. How?    forum.hibernate.org

Hi folks, I've got to fix a system that uses hibernate, but I'm new to it, like 2 min or so ... but 'cause so new to it I'm even having trouble googling for help! The current situation is the following: There's 1 table A with cols a, b, c that generates a class A with attributes a,b, c. How I ...

48. Mapping Help - ManyToMany Mapping with Single Join Attribute    forum.hibernate.org

I have two tables in a many to many relationship. Users ==== id: int name: string Raw Data: ==== id: int latitude: double longitude: double Raw Data Users ========== user_id: int raw_data_id: int selected: boolean I was wondering which method would be the best way to handle the many to many mapping such that I could get the select value from ...

50. Update object attribute from another object's prepersist    forum.hibernate.org

Hi, For some reasons, in our system, we'll have to update the version number of a parent object whenever its child object is being updated. (they're having OneToMany relationship and cascade all) We have created an unit test which updates one of the attributes of the parent object in the prepersist callback of the child object. Hibernate looks working fine with ...

51. Fetch attribute help needed    forum.hibernate.org

Beginner Joined: Sun Oct 14, 2007 7:29 pm Posts: 23 Hello, I am still somewhat new to Hibernate and trying to undrestand the fetch attribute of associations. I don't quite understand the implications of comibining fetch = "join|select" with lazy = "false|ture" and was hoping to get some guidance. I have four scenarios below with a sample mapping file -- would ...

52. Attribute "not-found" must be declared for element    forum.hibernate.org

Hi, When I try to load the following hbm file I get this exception. - Error parsing XML: XML InputStream(40) Attribute "not-found" must be declared for element type "many-to-one". I checked the hbm file and it has not-found attribute specified and I also observe that that not-found clause in hibernate has a default value also. Can you please guide me? ################### ...

53. Regarding formula attribute    forum.hibernate.org

Hi, ParentMessage and Message are the tables. I have a collection field called "messages "in the "ParentMessage" entity class. Now i want to get the name of the message which is having the maximum amount for each ParentMessage? Here name and amount are the columns in the Message table. I have declared one-to-many and many-to-one mappings in both the mapping files. ...

54. Regarding formula attribute    forum.hibernate.org

Hi, ParentMessage and Message are the tables. I have a collection field called "messages "in the "ParentMessage" entity class. Now i want to get the name of the message which is having the maximum amount for each ParentMessage? Here name and amount are the columns in the Message table. I have declared one-to-many and many-to-one mappings in both the mapping files. ...

55. length attribute missing on @Index annotation    forum.hibernate.org

56. Order by attribute in Joined Class    forum.hibernate.org

58. Attribute cascade doesnt work for me    forum.hibernate.org

El programa intenta grabar un lugar de estacionamiento antes que un usuario, porque eso es exactament lo que el "cascade" le est indicando que haga. Sin embargo, la estructura de tablas probablemente funciona en sentido opuesto, es decir, se necesita primero un lugar, y luego uno o ms usuarios que se refieran a l. Nota que, segn la secuencia de tu ...

60. IQurey expression for enum property that flags attribute add    forum.hibernate.org

hi my class have a property named WorkType (enum) that added flags attribute. this property keep multiple enum value (FullTime | PartTime | Freelance). i want query using IQuery interface, but can't do it:( my query; (for example, my enum property value is "FullTime | PartTime | Freelance") IQuery query = Session.CreateQuery("select a from Entity.Advert a where a.WorkType = :p1 or ...

61. Updating other attributes in the intersection table    forum.hibernate.org

This question is very common. As soon as you start putting extra information in the relationship table, even just a couple of extra files, it is not a relationship table anymore, but another entity. You should decompose your many-to-many relationship into one one-to-may relationship between contacts and contacts_custodians, and another many-to-one relationship between contacts_custodians and custodians. Very few real-life applications manage ...

62. Persisting Derived Attributes    forum.hibernate.org

Hi, think of the following scenario: you have a class Person with firstname and surename, both with getters and setters. Since your table is large you want to avoid a full table scan when doing queries and therefore introduce an additional "SEARCH_NAME" column with an index. In the Java class you have a derived attribute returning this search name: public String ...

63. Override an attribute and declaring it as @Id    forum.hibernate.org

@MappedSuperclass class User { private String username; // setters/getters... } @Entity class SubUser extends User { // How can I specify that I want the // inherited username to be the PK of this entity (@Id) // without changing the definition of User??? } ...

65. lazy attribute on many-to-many    forum.hibernate.org

66. Version attribute not refreshed in my Object    forum.hibernate.org

Yes, merge returns a merged instance of your entity, it does not reattach the current object, it copies it's state to a managed instance. Notice that the version number is not incremented immediately after calling merge(), because on session.merge() the state of the object is not flushed to the database, so the version number is not incremented. The number is updated ...

67. How to add "owner" attribute when owner class vari    forum.hibernate.org

I am adding a new feature to legacy code (i.e. I can't make large changes to old tables, especially no primary key changes). I am adding a Set of 'NewAttribute' items to several non-associated legacy classes which are represented in separate tables. I want these 'NewAttribute' items to live in a single database table and have an Owner attribute which maps ...

68. How to create a query with attribute length > 0    forum.hibernate.org

71. A question with cache attribute usage when using Ehcache    forum.hibernate.org

Hi All , If one configures Ehcache as second level cache with Hibernate and uses a READ_WRITE strategy as say "Then my understanding with respect to above is that " Whenever there is a change of the entity at the database level the cache is also updated simultaneously " please tell me if i am right or wrong on ...

72. request for clarification about the 'length' attribute    forum.hibernate.org

HI Simonm, Actually, length specify the lengh of the column of the perticular column, if u specify the length=50 ,then it will accept only 50 characters...... and if you not specify the length then hibernate intrnally specifies the length 255 for string type;;;(sorry for my english) ok.. ---------------accept only 2 char.

73. Persist only an id attribute of an object    forum.hibernate.org

Hello, did you try making the Y attribute Transient (with the @Transient annotation)? If you only want to store Y's id you can create an attribute Yid in class X, and store that attribute in the DB instead of Y. You can use @PrePersist and @PostLoad events to load Yid and your real Y respectively. Hope that helps in some way. ...

74. Self Many-to-Many Relationship with attributes    forum.hibernate.org

I solved it doing this: Code: @Entity @Table public class A { ... private int id; ... private Set relationshipsOwner; //Relationships as Owner private Set relationshipsRelated; //Relationships as Related ... @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(unique = true, nullable = false) ...

75. Criteria object can't access attribute?    forum.hibernate.org

Hello, I am new to Hibernate and am having problems accessing an attribute in my class with a Criteria object. This particular attribute is a class, and I need to query on one of that class's attributes. I can get one of the attributes, and I'm wondering if there is a "better" way to get attributes that are part of a ...

76. catalog attribute is sometimes ignored    forum.hibernate.org

Hello users, I encountered the following problem with the catalog attribute in a hibernate mapping. Consider the following example: You have configure hibernate to use 2 databases ("db1" and "db2") where "db1" is the default one. And you have defined a mapping for a class "A" that is mapped to a table "tab_a" in database "db2" via the catalog attribute. Then ...

77. Inheritance mapping: Accessing root class attributes/columns    forum.hibernate.org

9.1.4. Mixing table per class hierarchy with table per subclass You can even mix the table per hierarchy and table per subclass strategies using the following approach: ... ... ...

78. "generated" attribute of "property" tag inserts NULL value    forum.hibernate.org

Hi, Thanks for your reply. That would work, but it seems that my particular case, that an interceptor would have additional overhead without much gain. Since I'm using envers and the only entities that I track the update time are all audited, this is a mute point. I'll just leave the code to set the date in the constructor. Thanks, Walter ...

79. Cross-reference with attributes in table    forum.hibernate.org

Hi, I have been running into a problem with a table structure and trying to get it mapped properly to do cascading deletes. I have been reading over some web sites about how to deal with a many-to-many relationship and working with a cross-reference table. I am fairly comfortable on the concept and have my domain objects setup and working. My ...

80. unsaved-value attribute in hibernate    forums.oracle.com