-->
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.  [ 3 posts ] 
Author Message
 Post subject: Using @Id and @DocumentId on different properties? Possible?
PostPosted: Mon Jan 31, 2011 10:55 am 
Newbie

Joined: Tue Jan 25, 2011 1:15 pm
Posts: 8
Hi everyone, I am trying to index many tables on my project, currently all DB tables (All entities extend AbstractRecord) have as primary key an identity column populated with the generate_unique function. However since I have several tables and these column numbers will repeat amongst the tables when doing a search through Hibernate I will get class object instantiation exceptions.. Therefore I need to preserve the primary_key generation as it is, but have a unique identifier for all rows for all tables of my DB using the @DocumentId on a different property than the primary key itself.
Find in the following what I am trying to do:
Code:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class AbstractRecord
    implements Serializable
{
    //~ Instance variables ---------------------------------------------------------------
/** SERIALID */ public static final String SERIALID = "hyzmfgSwl5hsDbxZIitNILMT2/eiPYJErJcqIMun3/PVy3SbbiQie4k9lLnL450BhwL8EnUMyc+wrhgZtUBTdG9/YUuJ+ni/FRAdRGzTy7UrQI7opbrYRYehDUwj3hg9";
    /** id for this record. */
    @Id   <------------------------------------------------------------------------------------------------------------------------
    @GeneratedValue(strategy = GenerationType.TABLE)
    @Column(name = "id", nullable = false)
    private Integer id;

    /** line number for this record. */
    @Field(index=Index.UN_TOKENIZED, store=Store.NO)
    @Column(name = "record_number", nullable = false)
    private Integer recordNumber;

    /** record types for this record. */
    @Field(index=Index.UN_TOKENIZED, store=Store.NO)
    @Column(name = "record_type", nullable = false)
    private Integer recordType;

    /** Current status for this record. */
    @Field(index=Index.UN_TOKENIZED, store=Store.NO)
    @Column(name = "record_status", nullable = false)
    @Enumerated(EnumType.ORDINAL)
    private RecordStatus recordStatus;

    /** unique table key for the file. */
    @Field(index=Index.UN_TOKENIZED, store=Store.NO)
    @Column(name = "unique_table_key", nullable = false)
    private String uniqueTableKey;

    @DocumentId <------------------------------------------------------------------------------------------------------------------------ // Possible????
    @Field(index=Index.UN_TOKENIZED, store=Store.YES)
    @Column(name = "row_id", nullable = false)
    private String rowId;

    // Getters, setters, etc...

When performing the indexation and later search of documents the results are 0, however when I return the documentId annotation to the "id" property the results are retrieved, however for particular searches I get the exception mentioned above.. Any help/ideas/suggestions?
Thanks


Top
 Profile  
 
 Post subject: Re: Using @Id and @DocumentId on different properties? Possible?
PostPosted: Wed Feb 02, 2011 12:29 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Which version of Search are you using?
Did you have a look into the index with Luke to check what gets indexed?


Top
 Profile  
 
 Post subject: Re: Using @Id and @DocumentId on different properties? Possible?
PostPosted: Wed Feb 02, 2011 12:40 pm 
Newbie

Joined: Tue Jan 25, 2011 1:15 pm
Posts: 8
Hi Hardy, I resolved the problem via the Hibernate IRC channel..

Regarding your question, when the @DocumentId was on a different property than the @Id on no indexation was performed, I checked with Luke and the indexes were empty, when returning the annotation to the @Id property the indexation was done successfully!

For anyone who cares I had my Data Base primary key located on an abstract class and had many different Data Base tables inheriting from that abstract class @Id
The solution proposed was to move all properties from my abstract classes onto my concrete classes, therefore each concrete class had its own @Id.
Nevertheless it is apparently possible to use @Id and @DocumentId on different properties through an appropriate data model..


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.