-->
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: Field mapped as tinyblob - alternatives? [Solved]
PostPosted: Wed Apr 04, 2007 9:23 am 
Beginner
Beginner

Joined: Fri Jun 30, 2006 6:54 am
Posts: 20
Location: Germany
Hello Forum,

I'm using JBoss 4.0.5GA in conjunction with EJB 3.0.
I have a problem with correctly mapping fields of custom class objects.

Consider the following scenario:

We are developing an application which is divided into three sub projects.
One of that is the "ConfigManager" module able to create configuration data
that is used in our "Worker" project.

The "ConfigManager" project contains an entity class named "Account".
The "Account" class is used within the worker project to log into a SAP
system and gather some system data.

In order to be able to use this "Account" class in both sub projects I created
a separate jar which contains our entity classes only. I have deployed this entity jar in the JBoss's lib folder of the server instance I use.
Perfect so far everything works as expected.

Now I encounter the following problem:
I have create the entity class "RequestedData" in the "Worker project" that stores
the data read from the SAP system. This "RequestedData" class contains
a field of type "Account" from the commonly used entity jar.
The corresponding table is created by the hbm2ddl auto feature after I've
explicitly referenced the "Account" in the persistence.xml of the worker project.

The corresponding table for class "RequestedData" contains a column for
the property account of type "Account" but the data type is tinyblob.

It would be much nicer if I were able to tell JPA/ Hibernate that it shall
store the data of the Account field within the corresponding table and use the id of that entity as foreign key within the table for the "RequestedData"
class.
To make it a bit more clear - I dont't want the Account field of the "RequestedData" class to be stored as tinyblob - I like to have the foreign key id of the "Account" table associated with it.

I tried to use the @SecondaryTable annotation but that doesn't work.

I hope I was able to line out what I'm trying to do and someone can point
me to the right direction.

Any help would be greatly appreciated.

Best regards,

Henning Malzahn


Last edited by Henning Malzahn on Thu Apr 05, 2007 5:34 am, edited 3 times in total.

Top
 Profile  
 
 Post subject: Maybe not clear what I want?
PostPosted: Thu Apr 05, 2007 3:48 am 
Beginner
Beginner

Joined: Fri Jun 30, 2006 6:54 am
Posts: 20
Location: Germany
Hello Forum,

hmm... - some views but no ideas - maybe not clear what I want?

I'm trying to be a bit more detailed:

Class Account:

Code:
@Entity
@Table(name = "account")
public class Account {

    private long id;
    private String username;
    private String password;

    ... get- and set-methods skipped...
}


To be able to use this class in all sub projects all entity classes are packaged
in one "entity-business-jar file":

Code:
entity.jar
   |- Account.class
   |- ...


This entity.jar is deployed on the JBoss underneath the lib folder of the
used server instance:

Code:
jboss-root
    |-deploy
          |-workerEjb3-Project.ear
    |-lib
       |-entity.jar
       |...


The worker project contains a class "RequestedData":


Code:
@Entity
@Table(name = "requested_data")
public class RequestedData {

    private long id;
    private Account account;

    ... get- and set-methods skipped...

}


After referencing the "Account" class explicitly in the persistence.xml file
of the "workerEjb3-Project.ear" project all necessary tables are created
by the hbm2ddl-auto feature.

The created tables are:

Code:
----------------------account----------------------------
| Field                   |    Type                                 
|----------------------------------------------------------
| id                       |    bigint                                 
| username            |    varchar(32)                       
| password             |    varchar(32)                       
-----------------------------------------------------------

----------------------requested_data-------------------
| Field                   |    Type                                 
|----------------------------------------------------------
| id                       |    bigint                                 
| account               |    tinyblob                             
-----------------------------------------------------------


But unfortunately that's not what I want - I would prefer:


Code:
----------------------account----------------------------
| Field                   |    Type                                 
|----------------------------------------------------------
| id                       |    bigint                                 
| username            |    varchar(32)                       
| password             |    varchar(32)                       
-----------------------------------------------------------

----------------------requested_data-------------------
| Field                   |    Type                                 
|----------------------------------------------------------
| id                       |    bigint                                 
| account               |    bigint  <-- Foreign key       
-----------------------------------------------------------


So I would like to tell the persitence manager that it shall store the "Account" related data in the "account" table and only keep a foreign key
to the id of the "Account" instance.

Hope that outlines the problem more precisely...

Best regards,

Henning Malzahn


Top
 Profile  
 
 Post subject: Sorry for that stupid question...
PostPosted: Thu Apr 05, 2007 5:33 am 
Beginner
Beginner

Joined: Fri Jun 30, 2006 6:54 am
Posts: 20
Location: Germany
Hello Forum,

sorry for that stupid question...
A simple @OneToOne-Mapping is all I need...

Best regards,

Henning Malzahn


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.