wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes Annotation Table Name VS Entity Name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Annotation Table Name VS Entity Name" Watch "Annotation Table Name VS Entity Name" New topic
Author

Annotation Table Name VS Entity Name

lavnish lalchandani
Ranch Hand

Joined: Feb 28, 2007
Posts: 79
Hi



one can give the DB table name using @Entity (name="") or @Table (name="")
not sure whats the difference between two ??


lavnish.blogspot.com
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30050
    
149

While @Entity takes an optional name, it isn't a table name. It is for the case where you want to refer to the entity using a different name in JP QL queries. @Table's name attribute is the actual table name.

@Table's name is used a lot. @Entitiy's name is much rarer. It is useful if you have two @Entity classes' with the same name and you need a way to differentiate them when running queries.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
lavnish lalchandani
Ranch Hand

Joined: Feb 28, 2007
Posts: 79
got it , thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Annotation Table Name VS Entity Name
 
Similar Threads
Annotations doubt
About Named Queries
Create tables in different database schemas using EJB 3 Entity Persistent
Get Table name from entity name
JPA-Unknown entity type error when i actually have the entity in my DB