-->
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: Can I user Oracle database object types with Hibernate?
PostPosted: Tue Jan 06, 2004 9:44 am 
Newbie

Joined: Sat Jan 03, 2004 5:13 am
Posts: 4
orcal is a Object-Relation DBMS, so it can create the object type like Object-Oriented object.

for example:
CREATE TYPE product_typ AS OBJECT (
id NUMBER,
name VARCHAR2(10),
description VARCHAR2(22),
price NUMBER(5, 2),
days_valid NUMBER,

-- declare the get_sell_by_date() member function([i]method),
-- get_sell_by_date() returns the date by which the
-- product must be sold[/i]
MEMBER FUNCTION get_sell_by_date RETURN DATE
);

CREATE TYPE BODY product_typ AS
MEMBER FUNCTION
get_sell_by_date RETURN DATE IS
sell_by_date DATE;
BEGIN
SELECT
days_valid + sysdate
INTO
sell_by_date
FROM
dual;
-- return the sell by date
RETURN sell_by_date;
END;
END
;

-- create the tables with oracle object type like this
CREATE TABLE products (
product product_typ,
quantity_in_stock NUMBER
);

When insert row to table products, I should do like this:
INSERT INTO products (
product,
quantity_in_stock
) VALUES (
product_typ(2, 'Sardines', '12 oz box of sardines', 2.99, 5),
25
);

When I select rows from table products ,the statement like this:
SELECT p.product FROM products p WHERE p.product.id = 1;
the result like this:
PRODUCT(ID, NAME, DESCRIPTION, PRICE, DAYS_VALID)
----------------------------------------------------------------------
PRODUCT_TYPE(1, 'Pasta', '20 oz bag of pasta', 3.95, 10)


SELECT * FROM products;
PRODUCT(ID, NAME, DESCRIPTION, PRICE, DAYS_VALID) QUANTITY_IN_STOCK
---------------------------------------------------------------------------------------------
PRODUCT_TYP(1, 'Pasta', '20 oz bag of pasta', 3.95, 10) 50


update row in table products like this:
UPDATE products p
SET p.product.description='30 oz bag of pasta'
WHERE p.product.id=1

can i map the table products to Java class with Hibernate?
if yes, then how can i do for this
?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 06, 2004 10:19 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
There is no builtin way to do this. You could write a custom ClassPersister, this is however not an easy thing to do.


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.