-->
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.  [ 9 posts ] 
Author Message
 Post subject: hello,about hibernate view
PostPosted: Mon Nov 28, 2005 4:57 am 
Newbie

Joined: Tue Nov 22, 2005 3:19 am
Posts: 6
I need it to replace the view of database,but i can't find any article(forgive my idea),who can tell me some urls?
thanks very much!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 28, 2005 5:35 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
huh?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 3:28 am 
Newbie

Joined: Tue Nov 22, 2005 3:19 am
Posts: 6
what is it ?
can u help me?
max wrote:
huh?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 3:33 am 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
this is your second chance.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 8:28 pm 
Newbie

Joined: Tue Nov 22, 2005 3:19 am
Posts: 6
o ,what are you talking about ??


!@#$%^&*)(+

dennisbyrne wrote:
this is your second chance.


Top
 Profile  
 
 Post subject: Please rephrase your question.
PostPosted: Thu Dec 01, 2005 8:54 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
I think they want you to paraphrase your question so that they can understand it. Noone can understand your original question.

What do you mean by "view of the database"? Do you want to replace your schema entirely? Do you want to change how your java app talks to the database, but keep the existing tables and data? Either way, read the reference docs (on www.hibernate.org) or buy Hibernate In Action.. when it's out for Hibernate 3.


Top
 Profile  
 
 Post subject: Re: Please rephrase your question.
PostPosted: Thu Dec 01, 2005 9:39 pm 
Newbie

Joined: Tue Nov 22, 2005 3:19 am
Posts: 6
en , I get it,let me write more words:

I have two business object: Contract and Product, contract is make out when businss trade is to be in process, product is the product of the contract, that is :which goods i will sell out in this contract. So one contract may contains one or more products (there is a contractId field in the product).
My old idea is : create two entity(table) in the database,then create a view entity:
create view ContractAndProduct as select c.contractShorter,c.contractNumber,p.productName from Contrat c,Product p where p.contractId=c.contractid;
then mapping three entity:Contract.hbm,Product.hbm,ContractAndProduct.hbm,
and I also get three Java Object:
Contract.java,Product.java,ContractAndProduct.java
If I want to get the contracts that contain specify product,I can submit a query to ContractAndProduct.java, the hql may like this:
from ContractAndProduct cp where cp.productName ='ABC';
then I will show the search result on the web page.

It is my OLD idea,my new idea is to create a view entity in hibernate,not in database,so the database only exist two table entity:Contrat and Product,the view ContractAndProduct exist in hibernate ,not in database, in this case ,i can write the hql like old:
from ContractAndProduct cp where cp.productName ='ABC';

that is what I mean about "a view of hibernate" , but I dont know how to get it work.

notice: my system is more complex than it , I MUST get only A java object to query, so do not tell me like this : " select c.contractNumber,p.productName from ..........."

I think I have describ my question clearly ,may you have patience.

Thank you very much !!!



tenwit wrote:
I think they want you to paraphrase your question so that they can understand it. Noone can understand your original question.

What do you mean by "view of the database"? Do you want to replace your schema entirely? Do you want to change how your java app talks to the database, but keep the existing tables and data? Either way, read the reference docs (on www.hibernate.org) or buy Hibernate In Action.. when it's out for Hibernate 3.


Top
 Profile  
 
 Post subject: Re: Please rephrase your question.
PostPosted: Thu Dec 01, 2005 9:46 pm 
Newbie

Joined: Tue Nov 22, 2005 3:19 am
Posts: 6
notice: my system is more complex than it , the query hql MUST reference to only A java object, not two or more


so do not tell me like this : " select c.contractNumber,p.productName from ..........."

the legal hql may like this:
from Foo foo where foo.attA='A' and attB='B'

the Object Foo canbe any plain java ojbect ,(of course you must make sure cat get query result )


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 02, 2005 12:37 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
I'm still not getting it, but have you read up on entity relationships in hibernate? It looks to me like you need a <set> in Contract, which contains Products. The resulting SQL, when you load a Contract, would amount to something like (pseudocode):

Contract c = Hibernate.(select * from ContractTable)
c.getProducts() = Hibernate.(select * from ProductTable where ContractID = c.ContractID)

Each query will refer to only one table. If you want to be explicit about that, you just specify fetch="select" in the set's mapping.


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