• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get Table name from entity name

 
Kushagra Bindal
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!!.


Thanks
Kushagra Bindal
 
rani vini
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic