-->
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.  [ 1 post ] 
Author Message
 Post subject: Problem with table and column name hyphen ( ‐ ).
PostPosted: Fri Aug 17, 2007 1:27 pm 
Newbie

Joined: Tue Jul 24, 2007 1:52 pm
Posts: 5
Hello,
I have these relations:

EmpresaProfissionalDTO
Code:
@Entity
@Table(name="\"sim-empresa-prof\"", schema="PUB")
public class EmpresaProfissionalDTO implements Serializable {

   @Id
   @Column(name = "\"num-empresa-prof\"")
   private String sqEmpresaProfissional;

   @Column(name = "cargo")
   private String cargo;

   @ManyToOne(fetch = FetchType.LAZY)
   @JoinColumn(name="\"num-profissional\"", insertable = false, updatable = false)
   private ProfissionalDTO profissional;

   @ManyToOne(fetch = FetchType.LAZY)
   @JoinColumn(name="cnpj", insertable = false, updatable = false)
   private EmpresaDTO empresa;


ProfissionalDTO
Code:
@Entity
@Table(name="\"sim-profissional\"", schema="PUB")
public class ProfissionalDTO implements Serializable {
   @Id
   @Column(name = "\"num-profissional\"")
   private Long sqProfissional;
   @OneToMany(targetEntity = EmpresaProfissionalDTO.class ,mappedBy="profissional", cascade= javax.persistence.CascadeType.ALL)
   @Cascade(value = CascadeType.DELETE_ORPHAN)
   @Fetch(FetchMode.SUBSELECT)
   private Set<EmpresaProfissionalDTO> empresaProfissional;


EmpresaDTO
Code:
@Entity
@Table(name="\"sim-empresa\"", schema="PUB")
public class EmpresaDTO implements Serializable {

   @Id
   @Column(name = "cnpj")
   private String cnpj;

   @OneToMany(mappedBy="empresa", cascade= javax.persistence.CascadeType.ALL)
   @Cascade(value = CascadeType.DELETE_ORPHAN)
   @Fetch(FetchMode.SUBSELECT)
   private Set<EmpresaProfissionalDTO> empresaProfissional;


The EmpresaProfissionalDTO is the relation between ProfissionalDTO and EmpresaDTO.

I make this:
Code:
   StringBuffer sb = new StringBuffer(" FROM ProfissionalDTO as c");
   sb.append("    left join c.empresaProfissional s ");
   sb.append(" where c.sqProfissional = :pChave ");
         
   Query q = session.createQuery(sb.toString());
         
   q.setLong("pChave", chave);
         
   result = (ProfissionalDTO) q.uniqueResult();


but the hibernate don't put the "" in the left join... the select created by hibernate is this:
Code:
select columns..... (just cut because the size..)
  from PUB."sim-profissional" profission0_
  left outer join PUB."sim-empresa-prof" empresapro1_ on profission0_."num-profissional" =
                                                         empresapro1_.num-profissional
where profission0_."num-profissional" = ?


see in left outer join...
profission0_."num-profissional" = empresapro1_.num-profissional
he dont put the "", and makes return a Exception, because he dont find that column..

How can I make this works?

Ps: I can't change the name of tables and columns... =/

Sorry my bad english...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.