• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dealing with Custom User Types as an Array in Hibernate

 
jai shreeram
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have 2 tables

Table A:

number number,
name1 varchar20,
name2 varchar20,
name3 varchar20,
name4 varchar20,
name5 varchar20,
name6 varchar20,
name7 varchar20,
name8 varchar20,
name9 varchar20,
name10 varchar20,
name11 varchar20,
name12 varchar20,
name13 varchar20,
name14 varchar20,
name15 varchar20.

etc..

Table B:

name varchar20,

x number,

y number,

etc...

name field on Table B is refered by all the 15 columns of Table A.

Pojos:

A.java:

private B b1;
private B b2;
private B b3;
private B b4;
private B b5;
private B b6;
private B b7;
private B b8;
private B b9;
private B b10;
private B b11;
private B b12;
private B b13;
private B b14;
private B b15;
private Integer number;

etc..

B.java:

private string name;

private Integer x;

private Integer y;

etc..

Hbms:

A.hbm.xml:

15 number of many-to-one mappings for B.java.

etc....

B.hbm.xml:

Properties for all the columns of B table.

15 number of collections for table A, for each of the 15 columns.


My requirement:

Instead of writing 15 properties in A.java.

Can I have an Array of object type B, in A.java.

It will be more convenient, and flexible.

Thanks in advance,
Ramana Reddy
[ April 16, 2007: Message edited by: jai shreeram ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure I understand your data model. Can you post the DDL?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, exactly the title of your topic. In order to achieve what you want, you will have to create your own Custom UserType that will read the data from the database and you will code the construction of that Collection of type Bs. There is no regular mapping that you can do to achieve that with the data model that you have.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic