embed 2 « Map « JPA Q&A





1. any way to embed sql in hsql?    forum.hibernate.org

Hibernate version: 2.1.7 I would like to use hsql to gain the benefit of automatic joining and cacheing but would like to embed sql to use the "top" command. I know that top can usually be replaced with setMaxResults() but, in this case, it is a sub query (using MS SQL 2000). Is there any way I can do this? select ...

2. problem with @Embedded and @EmbeddeSuperclass    forum.hibernate.org

3. How to embed an Update SQL into hibernate mapping file?    forum.hibernate.org

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.RangeCheck(ArrayList.java:547) at java.util.ArrayList.get(ArrayList.java:322) at org.hibernate.hql.ast.HqlSqlWalker.postProcessUpdate(HqlSqlWalker.java:390) at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:164) at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83) at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:427) at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:388) at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:291) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)

4. Must we embed all subclasses in super class' mapping file?    forum.hibernate.org

If we are implmenting inheritance via the table-per-hierarchy () or table-per-subclass () strategies then it appears, at least from all the samples that I have seen, that the mapping definitions for the subclasses must all be embedded into the mapping definition of the super class. Is this correct? If so is there anyway around this? It seems that on some multilevel ...

5. How to embed "NOW()" into column?    forum.hibernate.org

Author Message funkhouser Post subject: How to embed "NOW()" into column? Posted: Fri Dec 02, 2005 1:08 pm Newbie Joined: Mon Nov 21, 2005 1:48 pm Posts: 17 Using XDoclet, I'd like to know how to force that SQL Server's "NOW()" operation is called on a specified column (see timestamp below) when inserting new rows. Is this even possible? ...

6. Understanding 'order by' for a field in an @Embedded object    forum.hibernate.org

Newbie Joined: Wed Feb 08, 2006 10:31 am Posts: 3 I can't figure out how to do an 'order by' for a field that is declared in an @Embedded object. Hibernate version: hibernate 3.1.1 hibernate annotations 3.1beta7 Mapping documents: I'm using annotations. Code snippet from Product class Code: public class Product implements Serializable { @Id(generate = GeneratorType.AUTO) ...

7. Embedded object and inheritance problem    forum.hibernate.org

Hibernate version: 3.1.3 Hibernate annotations version: 3.1beta8 Name and version of the database you are using: mysql 4.1.12a Dialect: org.hibernate.dialect.MySQLInnoDBDialect Hi, I am having a problem when embedding an object using the @Embedded annotation. The problem is that Hibernate does not correctly map the embedded class attributes. I think this could be related to the fact that the embedded object is ...

8. Problems with embedded (in process) Derby BLOB data type    forum.hibernate.org

Hi, I am using Hibernate with Hsqldb as embedded (in process) DB engine in my application. I tried to add support for Derby (now derby.apache.org). It works OK in server/client mode, but it fails in embedded mode with error: 2006.04.26-11:14:42 [http-8080-Processor24] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 20000, SQLState: 22005 2006.04.26-11:14:42 [http-8080-Processor24] ERROR org.hibernate.util.JDBCExceptionReporter - An attempt was made to get a ...

9. Allow embedded type information for s.    forum.hibernate.org

Hi, I'm using the persistent enum approach that is most easily found on the web to persist a set of enums. I have this done through an user type, like this: Code: ...





10. embed-xml at run    forum.hibernate.org

I have the same question. It seems that embed-xml overrides the lazy and fetch attribute. I don't think that it should. embed-xml should mean, if the associated entity is initialized (as determined by lazy and select), then the full xml for that entity will be written to the Element. Then you could determine the hydration of the xml at the query ...

11. How to embed SQL select statement in the Mapping XML file    forum.hibernate.org

Hi All, I'm new to this forum and also to Hibernate. I'm facing a problem can anyone help me out. I'll just try to explain the problem with an example. I have two tables A and B. Table B contains some String with a corresponding Integer values (key value pair consider it that way). Now I want to insert values in ...

12. Embedded Generic    forum.hibernate.org

Hi, I'm using Hibernate annotations and I'm trying to make en embedded generic class persistent @Embeddable class Manager { @OneToMany(cascade = CascadeType.All, targetEntity=PersistentObject.class) List objects = new ArrayList(); //Getter und Setter .... } Another class uses this Manager class for different persistentObject subclasses @Entity class Person extends PersistentObject { @Embedded Manager phoneNumberManager = new Manager(); @Embedded Manager

addressManager = ...

13. Inheritence of Embedded objects (@Embeddable)    forum.hibernate.org

Newbie Joined: Wed Oct 18, 2006 6:34 pm Posts: 4 Hi there @Hibernate (must be a pretty often repeated joke in here...) I have an @Embeddable object AllocationId which extends another @Embeddable object (GenericId). AllocationId, is simply a marker class and has NO attributes in it, while all attributes (String id; which I want to persist) are in GenericId (inherited in ...

14. Hibernate JACC in the ejb3 embedded container    forum.hibernate.org

2006-10-24 15:28:17,307 DEBUG [org.hibernate.secure.JACCConfiguration] adding permission to role Use r: (javax.security.jacc.EJBMethodPermission net.pay.security.entity.Payment insert)[*:insert()] 2006-10-24 15:28:17,307 DEBUG [org.hibernate.secure.JACCConfiguration] adding permission to role Use r: (javax.security.jacc.EJBMethodPermission net.pay.security.entity.Payment update)[*:update()] 2006-10-24 15:28:17,307 DEBUG [org.hibernate.secure.JACCConfiguration] adding permission to role Use r: (javax.security.jacc.EJBMethodPermission net.pay.security.entity.Payment read)[*:read()] 2006-10-24 15:28:17,307 DEBUG [org.hibernate.secure.JACCConfiguration] adding permission to role Adm in: (javax.security.jacc.EJBMethodPermission net.pay.security.entity.Payment delete)[*:delete()]

15. Embedding an Object    forum.hibernate.org

Basically you need to map Pet with an id, and then use a many-to-one in Person. The generated Person table should have a foreign key to Pet. @Entity public Class Person{ long id; Pet pet; @Id public long getId() { return id; } public void setId(long id) { this.id = id; } @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) public Pet getPet() { return ...

16. Embedded Objects get set to null if all its members are null    forum.hibernate.org

I found this posting but have not found anything in the hibernate jira database. http://jira.jboss.com/jira/browse/HIBERNATE-50 I think this is a bug. Here is my example: Code: @Embeddable public class EmbeddableOne implements Serializable { private String field1; ... } @Embeddable public class EmbeddableTwo implements Serializable { private Boolean field1; ... ...





18. Hibernate + Embedded HSQL flushing delay problem    forum.hibernate.org

I've being using hibernate 3.2.4.sp1 + Hibernate Annotation 3.3.0.ga1 + hsql - 1.8.0.7 (standalone mode) as a lightweight backend for a small swing desktop application. I initialize hibernate using the standard HibernateUtil approach (which keep a static SessionFactory). everything works fine except data doesn't get written to the db file couple of seconds after the transaction. so If I start up ...

19. Newbie: How to map a embedded class that contains collection    forum.hibernate.org

Hi NG! I'm learning hibernate and have a - IMO - common task to solve. I've to persist the entities Class A, Class B, Person and an Embedded Class PersonsDelegate. They look like this: @Entity public class A { private PersonsDelegate personsDelegate; public PersonsDelegate getPersonsDelegate() { return personsDelegate; } public void setPersonsDelegate (PersonsDelegate personsDelegate) { this.personsDelegate = personsDelegate; } // ...plus ...

20. Embedded IllegalArgumentException: argument type mismatch    forum.hibernate.org

I am using Hibernate 3.3 with annotations. I have an embedded class (component) that I embed in two different classes. In one of the class, everything is working fine, but in second class I get Caused by: java.lang.IllegalArgumentException: argument type mismatch [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [java] at java.lang.reflect.Method.invoke(Method.java:585) [java] at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:42) [java] ... 53 more ...

21. Embedding without Annotations?    forum.hibernate.org

Hi, I would like to embed objects in my O/R-Mapping, the way you can do it with @Embeddable/@Embed etc. But my application must not use Java 5, so I cannot use Annotations. Can I use "embedding" with XML-mapping? I cannot find any instructions for that, so I fear the answer is no... ? Thanks, bee

22. reuse @entity for embedding    forum.hibernate.org

23. @Embedded property not rehydrating on an entity ....    forum.hibernate.org

Using Hibernate 3.2.2 Problem: When I save an entity that has an embedded component, without giving any values to the embedded component and then rehydrate the entity; the component is null. Code: @Embeddable public class MyComponent { @Column(columnDefinition="varchar(10)") private String text1; @Column(columnDefinition="varchar(10)") private String text2; ...

24. hql update of an embedded object    forum.hibernate.org

Hibernate version: 3.2.5 Hi, I'm trying to update an embedded object with a hql query but hibernate raise an exception. I'm trying something like "UPDATE Car SET speed = :speed WHERE id = :id" (speed is an @embedded attribute of car). An exception is raised at the session.createQuery : Code: org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: AND near line 1, column 38 [UPDATE ...

25. Subcriteria for Example via Embedded object    forum.hibernate.org

26. Subcriteria for Example via Embedded object    forum.hibernate.org

27. Embedding entity references in XMLTYPE column    forum.hibernate.org

For reasons I won't get into here, we need to pack a bunch of information into an XMLTYPE column. I've got a custom user type that converts back and forth between the XML that lives in the database and a Map in memory. Currently, I can store values in the Map such as lists, numbers, strings. That works like a charm, ...

28. How to make embedded object nullable    forum.hibernate.org

Is there a way to make an embedded field nullable if the fields of the embeddable object are not nullable? I have an embeddable object Coordinates which has non-nullable properties latitude and longitude. When referencing Coordinates in the Location class, that reference can be null. Is there a way to clarify this distinction using annotations? @Embeddable class Coordinates { private double ...

29. Embedded object and Embeddable class    forum.hibernate.org

Hello, is it possible using this mapping? An embeddable class B inside class A. Code: @Entity public Class A{ public A(){ b = new B(); } ... @Embedded private B b; .. public B getB(){ .. } public void setB(B b){ .. } @Embeddable Class B{ ...

31. Embedded Database    forum.hibernate.org

32. @CollectionId and accessing the PK of embedded objects    forum.hibernate.org

Hi all, I have an Item entity with a set of Images as a collection of embedded objects (similar to section 6.3.3 in the book Java Persistence with Hibernate): Code: @Entity @Table(name="item") public class Item { private Long id; private List images; ..... @CollectionOfElements @JoinTable(name="item_image", joinColumns=@JoinColumn(name="item_id")) ...

33. Setter for embedded value - lost update    forum.hibernate.org

34. Bugs with @OrderBy on embedded fields ?    forum.hibernate.org

******************** Hibernate version: hibernate3.2.6.ga ******************** stack trace of any exception that occurs: 23:03:22,765 WARN [ServiceController] Problem starting service persistence.units:jar=EntityGenDao.jar,unitName=genPersistUn it java.lang.NullPointerException at org.hibernate.cfg.annotations.CollectionBinder.buildOrderByClauseFromHql(CollectionBinder.java:851) at org.hibernate.cfg.annotations.CollectionBinder.bindOneToManySecondPass(CollectionBinder.java:608) at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:563) at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:517) at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1136) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:316) .../... ******************** Name and version of the database you are using: MySQL 5 ******************** I have the same problem. There is a JIRA about that : ...

35. trouble inserting by query on entity with embedded object    forum.hibernate.org

Hi, How do you insert multiple rows using Hibernate's Insert Select statement? My Project is using EJB3 and Hibernate's EntityManager. My Entity has an Embedded AuditEntry object that is giving me problems. I've tried various approaches but can't get it to work. Thanks for any help in advance. Hibernate version: 3.2.0.ga Mapping documents: @MappedSuperclass @AccessType("field") abstract public class ImmutableEntity extends BaseEntity ...

36. Are optional embedded properties possible?    forum.hibernate.org

I would like to use an @Embeddable object in my Entity, but it must be an optional (nullable) property. My entity looks like this (besides some other regular properties): Code: @Embeddable private static class Fubar { private String aap; ...

37. Embedding single table hierarchy    forum.hibernate.org

Hi all, We are trying to embed a single table strategy as one column in a table that represents another entity. In other words, we don't want a one-to-one relationship (with 2 tables), but instead we want the column to be part of the same table. Here's an example: public class Client{ private Long id; private int field1; private int field2; ...

38. embed hql in mapping files    forum.hibernate.org

Hello is there a way I can embed my hql in the mapping file then use a named query to execute it? FROM Cat WHERE owner= :owner Everything works great except I get a JDBCExceptionReporter telling me that "could not execute query [FROM Cat WHERE owner = ?]" It thinks it is sql not hql... ...

39. Embedded classes with ManyToOne attributes    forum.hibernate.org

Hello, I'm mapping a legacy table that has three types of addresses. My main entity class is Person and I created a component class called ContactInfo. Code: @Embeddable ContactInfo { @Column(name="address") String address; ... @ManyToOne Country country; } @Entity @Table(name="persons") Person { ...

40. Question on updating a collection of embedded entities    forum.hibernate.org

Hello! I have a Customer object which contains a unidirectional collection (Set) of ContactPersons (embedded entities). Cascading for this relation is set to "all,delete-orphans". It works correctly but what I'm wondering about is why Hibernate entirely deletes and re-inserts the ContactPersons every time I update the Customer. The object graph is in detached state as I get it from a remote ...

41. How to override an embedded field to transient    forum.hibernate.org

I would like to know if it is possible to override an embedded field to turn it transient. The use case is: @Embeddable public class Person { private String name; private Date dateOfBirth; ... @Column(name = "NAME") public String getName() { return name; } @Column(name = "BIRTH") public Date getDateOfBirth() { return dateOfBirth; } ... } @Entity public class Actor { ...

42. Help instantiating embedded objects with annotations.    forum.hibernate.org

Hello, Hibernate version:3.3.1 Annotations version: 3.4.0 MySql 5.1.11 It's not clear to me how to set up annotations for embedded objects. At this point, I'm just looking at the retrieval side. Guess I'd like to know how to retrieve stuff from the db via stored procedures and instantiate various embedded objects in the application. No problem calling stored procs....I'm using native ...

43. Sorting by columns from embedded entity - Criteria    forum.hibernate.org

Hi, Class Client { @Embedded Address address; } Class Address{ @Column(name="STREET") String street; } There is a problem in sorting query results by street. I know that when I sort by columns in referenced entities i have to add criteria for them. And that works fine. But there is a problem, when referenced entity is not separate column - STREET column ...

46. What is the diff between Embedding and Custom Mapping Type    forum.hibernate.org

Hi All, I'm now going to implement the GMT time in my application. It contains the time zone and the time value. At first, I planned to implement it by creating an embeddable class "GMT" for it. Since it will generate two db columns "timezone" and "time" in the table which contain the class "GMT". However, after reading an article, an ...

47. Embedded DB + Hibernate    forum.hibernate.org

Hi all, I am developing desktop application(SWT/SWING) and want to use embedded database + Hibernate. I need information on using embedded db with hibernate(choosing db, configuring, etc) I have been reading docs on using HSQLDB embedded with hibernate, but cannot finnaly understand how they are configured. Maybe I should choose another embedded DB, but which one I guess. Any help? Please ...

48. Need help mapping a collection of embedded objects?    forum.hibernate.org

Hello all, I need help mapping a collection of embedded objects. I have a Person class that implements a Person interface and has a one to many relationship to my EmailAddress class that also impments a EmailAddress interface. Both of these classes extends a Base class that is annotated with @MappedSuperclass. I emphasize the exists of the interfaces because I think ...

49. @Embedded / @Embeddable / @Parent (Mapping Back Pointer?)    forum.hibernate.org

@javax.persistence.Entity public class User{ @javax.persistence.Embedded private Location location; // other fields... } @javax.persistence.Embeddable public class Location { @org.hibernate.annotations.Parent private User user; // other fields... }

50. @Embedded: exclude column for embedded entity    forum.hibernate.org

51. Re: Error trying to map embedded to secondary table [SOLVED]    forum.hibernate.org

Hi there, I have a peculiar problem with Hibernate JPA. I seem to be unable to put an embedded entity into a secondary table. Here is a such an entity definition (put into orm.xml): Code:

...

52. Embeddable & Embedded    forum.hibernate.org

I have User table & User Auth table. User table has user information & auth table just stores the last logged in date. User configuration is defined in hbm file and we would like to use the facility provided by @Embeddable & @Embedded in xml configuration. Could someone explain how to do? User table has user id first name last name ...