wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes Get Table name from entity name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Get Table name from entity name" Watch "Get Table name from entity name" New topic

Get Table name from entity name

Kushagra Bindal
Ranch Hand

Joined: Oct 15, 2008
Posts: 156
Hi All,

I am using EJB3.0. I have few entityname of my entity. Is there a way to fetch the table name from that entity using proper annotation.

Please Help!!!.

Kushagra Bindal
rani vini

Joined: May 13, 2009
Posts: 24
You can use @Entity annotation. If this is not you are expecting please post the problem in detail
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

What is the need for the table name? How are you using the table name in code? There are @Entity and @Column annotations, but I don't believe they dynamically give you the name of the underlying table.

-Cameron McKenzie
Per Lindberg
Ranch Hand

Joined: Jan 17, 2008
Posts: 48
There are situations where it would be very useful to get e.g. the table and column names of an JPA entity.

I must implement a method to serialize a number of different JPA entities into SQL INSERT strings. Sure, you can hard-code the table and colum names, but it would be very nice if they could be retrived from the entity (instance or class).

Is that possible?

I agree. Here's the link: http://aspose.com/file-tools
subject: Get Table name from entity name
Similar Threads
Entity Bean with Multiple Tables
mapping one pojo with multiple tables
Back to front Entity bean generation in WebSphere 5.1
Hibernate and JPA - Creating Table
Create tables in different database schemas using EJB 3 Entity Persistent