These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Problems, when using @OneToMany with @JoinTable
PostPosted: Thu Aug 28, 2008 8:52 am 
Beginner
Beginner

Joined: Wed Jan 16, 2008 8:16 am
Posts: 23
Hi,

the mapping of the tables looks like following:

Code:
@Entity
@Table(name = "PROZESS")
public class Process extends BaseEntity {

    @Id
    @Column(name = "PROZESS_ID")
    private String id;

    @OneToMany
    @JoinTable(name = "TEXT2PROZESSE",
        joinColumns = { @JoinColumn(name = "MAP_ID")  },
        inverseJoinColumns = {  @JoinColumn(name = "TEXT_ID", rerencedColumnName = "TEXT_ID") })
    private List<TextResource> names;

}

@Entity
@Table(name = "TEXT_RESSOURCE")
@BatchSize(size = 50)
public class TextResource extends BaseEntity {

    @Id
    @Column(name = "ROWID")
    private String id;

    @Column(name = "TEXT_ID")
    private Long textId;

    @Column(name = "SPRACHE")
    @Type(type = "LocaleType")
    private Locale locale;
   
    @Column(name = "TEXT")
    private String text;

}


The entity model comes from a legacy system. As you can mention the TextResources are used for translation. Between Process and TextResource a mapping table is used (1:1 Process - Mapping, 1:* Mapping - TextResource).

If two or more Processes share one text resource the first record (id = 5) loads the TextResources correctly (of course, within one session):
5 ... 5850 de Nachanmeldung | 5850 en Subsequent Application | 5850 fr Demande ultérieure |

But the second one (id = 28) only gets the french translations - 3 times:
28 ... 5850 fr Demande ultérieure | 5850 fr Demande ultérieure | 5850 fr Demande ultérieure

I hope someone can help me. If have no idea, whether the are errors in configuration or there is a bug in hibernate.

Hibernate version: 3.2.5.ga
Name and version of the database you are using: Oracle 9i

Thanks in advance,
best regards,
michi


Top
 Profile  
 
 Post subject: Help me understand the loading of lazy collections
PostPosted: Mon Sep 08, 2008 11:12 am 
Beginner
Beginner

Joined: Wed Jan 16, 2008 8:16 am
Posts: 23
Hi,

unfortunately I didn't get an answer to my question. I debugged into the Loader class. The method of interest is the doQuery method.

- The first (for process with id = 5) I entered this method the local results variable has three entries where each TextResource holds only the id. The rest seems to be done within the initializeEntitiesAndCollections method.
- After calling this method (for process with id = 28) the second time, the results variable is already filled correctly (no only intialized).

The question are:
- What happens within the initializeEntitiesAndCollections method exactly? Is there read something from cache, snapshot or so?
- Is the results variable read anymore? It seems that this one won't be assigned anymore in future.

I hope that someone can help me.

Best regards,
michi


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.