-->
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: what is the difference between @Entity & @Table
PostPosted: Wed Nov 28, 2007 2:01 am 
Newbie

Joined: Tue Oct 30, 2007 5:08 am
Posts: 10
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hi,

as I am new to JPA I am having some qustions related to @Entity & @Table

in javax.persistence.Entity and
javax.persitence.Table
annotations we give the name of the Database Table, I mean @Entity having the attribute as "name" which mapped to a table, but some times we need some more atributes and we use @Table annotation which having more attributes available like catelog, schema etc like
@Entity
@Table(name="MyTable", schema="MySchema")

so my question are....

why there is a need of @Entity ???

for which type of functionalities we use @Entity and @Table annotations ?

what is the basic difference between @Entity and @Table ?

_________________
With Best Regards,
Ishaan


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 29, 2007 1:54 am 
Newbie

Joined: Tue Oct 30, 2007 5:08 am
Posts: 10
Hi,

Well I got the solution of my question from William Mo,

many many thank to William Mo,

according to him.....

Every bound persistent POJO class is an entity bean and is declared using the @Entity annotation (at the class
level).

@Table is set at the class level; it allows you to define the table, catalog, and schema names for your entity bean
mapping. If no @Table is defined the default values are used: the unqualified class name of the entity.

The @Table element also contains a schema and a catalog attributes, if they need to be defined. You can also
define unique constraints to the table using the @UniqueConstraint annotation in conjunction with @Table (for
a unique constraint bound to a single column, refer to @Column).

Entity is object-oriented and table is relation-oriented. You can only use the entity name in the HQL (Hibernate Query Language) to query objects, and the table name in the native SQL.

_________________
With Best Regards,
Ishaan


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.