onetoone « Query « JPA Q&A

1. Hibernate OneToOne with a specific clause

If somebody knows how-to: I have an entity

public class AnEntity {

    private String propertyA;
    private String propertyB;
    private String ...

2. JPA OneToOne like dependency

I'm trying Play Framework, now I have this situation: I have a SuperUser who is a Person with power, and I want to do this Persona entity like FK and so like ...

3. Hibernate query with two OneToOne Relationship

public class Usuario implements Serializable {

    private Long id;

    @Column(name = "con_codigo_usuario", unique = true, nullable ...

4. OneToOne outer join in HQL Query

Hello, I have a HQL query like this:. Code: SELECT destino FROM UnidadAlmacenamiento u JOIN u.tipoUnidad.tiposSalida tipo JOIN tipo.unidades destino WHERE u = :origen AND (destino.loteActual is null OR destino.loteActual.peso < destino.capacidad)) In UnidadAlmacenamiento Entity I have this @OneToOne: Code: @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.PERSIST) public Lote getLoteActual() { ...

5. problem in a delete where clause on a OneToOne relationship

Hi gonzao, I gave up because I'm too busy: I resolved it in java. I don't think it's the problem: it is translated to "id is null". The problem is that hibernate doesn't do an inner select but translates simple to "id is null" notice it's e.invoiceWorkDetail that must be null: that means in sql: there is no child in the ...

6. Unidirectional OneToOne relationship query

Hello, I am trying to create a simple OneToOne relationship but only want to define the relationship in the owner object. I have three classes: @Entity @Table(name="user") public class UserBean extends BaseEntity { @ManyToOne @JoinColumn(name="client_id") private ClientBean client; @Id @GeneratedValue(strategy=GenerationType.AUTO) @Column(name="user_id") private int id; @Column (name="name") private String name; @Column (name="password") private String password; ... } @Entity @Table (name="client") public class ...

7. OneToOne relationship and "is not null" query

ritesh_randomgmail wrote: Kaj, I am trying to understand this better. Would you mind positing the schema for your two tables? And if you feeling generous, then could you provide the ddl stmts that Hibernate used to created those tables? Thanks for answering! I have put a "desc" in sqlplus of the two tables at This is a legacy database we ...

8. bidirectionnal OneToOne and n+1 select

PhoneEntity { @OneToOne(mappedBy = "phone", fetch = FetchType.LAZY, optional = true) private SimEntity sim; ........ } SimEntity { @OneToOne(fetch = FetchType.LAZY) @JoinColumn(name = "`phoneId`", nullable = true) private PhoneEntity phone; ....... }

9. OneToOne-Or-Null LeftJoinFetch selection problem

Hibernate version: Let me first explain my database layout: -> There is a table called "TableParent" with a primary key and some columns -> There is a table called "TableChild" with a primary key, some columns and a foreign key to TableParent, which is unique and not null -> So there is a one to one-or-null relation between TableParent and ...