Hi. I'm trying to use EJB3.0 (latest) with PostgreSQL. I'm having some 
troubles, when I want to use postgresql reserved words for my table names, like 
this:

when i do a: select o.orderId from Order as o
  | hibernate generates: select order0_.order_id as x0_0_ from order order0_
  | the correct sql would be: select order0_.order_id as x0_0_ from "order" 
order0_ 

In other words, it does't escape table names as they should be. I found 
somewhere that I should add backticks (`) around my table name, but that was 
when I configure Hibernate with xml files. Since I'm using annotations, I'm 
doing this:
@Table(name = "`Order`")
Which works fine for entities that does not have relations. When I introduce 
them, it gets this error:
Caused by: org.hibernate.MappingException: Unable to find physical table: Order

Can anyone help me? Here is a more complete code sample:

Blah.java

  | @Entity
  | @Table(name = "`Blah`")
  | public class Blah {
  |     public int id;
  |     public String foo;
  | 
  |     public String getFoo() {
  |         return foo;
  |     }
  | 
  |     public void setFoo(String foo) {
  |         this.foo = foo;
  |     }
  | 
  |     @Id
  |     @GeneratedValue
  |     public int getId() {
  |         return id;
  |     }
  | 
  |     public void setId(int id) {
  |         this.id = id;
  |     }
  |     
  | }
  | 

Foo.java

  | @Entity
  | @Table(name = "`Foo`")
  | public class Foo {
  |     public int id;
  |     public Blah blah;
  | 
  |     @Id
  |     @GeneratedValue
  |     public int getId() {
  |         return id;
  |     }
  | 
  |     public void setId(int id) {
  |         this.id = id;
  |     }
  | 
  |     @ManyToOne
  |     public Blah getBlah() {
  |         return blah;
  |     }
  | 
  |     public void setBlah(Blah blah) {
  |         this.blah = blah;
  |     }
  |     
  | }
  | 

The error:

  | java.lang.reflect.InvocationTargetException
  |         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  |         at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
  | java:39)
  |         at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
  | sorImpl.java:25)
  |         at java.lang.reflect.Method.invoke(Method.java:585)
  |         at 
org.jboss.ejb3.ServiceDelegateWrapper.startService(ServiceDelegateWra
  | .............
  | .............
  |         at 
org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
  | loop(AbstractDeploymentScanner.java:218)
  |         at 
org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
  | run(AbstractDeploymentScanner.java:197)
  | Caused by: org.hibernate.MappingException: Unable to find physical table: 
Blah
  |         at org.hibernate.cfg.Mappings.getLogicalTableName(Mappings.java:473)
  |         at org.hibernate.cfg.Mappings.getLogicalTableName(Mappings.java:520)
  |         at 
org.hibernate.cfg.Ejb3JoinColumn.linkValueUsingDefaultColumnNaming(Ej
  | b3JoinColumn.java:270)
  |         at 
org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:194
  | )
  |         at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:44)
  |         at 
org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(Annotatio
  | nConfiguration.java:233)
  |         at 
org.hibernate.cfg.Configuration.buildMappings(Configuration.java:997)
  | 
  |         at 
org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.j
  | ava:722)
  |         at 
org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerCo
  | nfigurator.java:161)
  |         at 
org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Co
  | nfiguration.java:567)
  |         at 
org.hibernate.ejb.Ejb3Configuration.createContainerEntityManagerFacto
  | ry(Ejb3Configuration.java:245)
  |         at 
org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFa
  | ctory(HibernatePersistence.java:108)
  |         at 
org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnit
  | Deployment.java:260)
  |         ... 77 more
  | 

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3929098#3929098

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3929098


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to