-->
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.  [ 2 posts ] 
Author Message
 Post subject: doubts @ManyToOne
PostPosted: Mon Aug 19, 2013 10:37 am 
Newbie

Joined: Mon Aug 19, 2013 10:14 am
Posts: 4
The relationship '@ManyToOne' there any way that I can bring only the identifier of the relationship table without having to load the related entity?

Code:
@Entity
@Table(name = "City")
public class City {

   private static final long serialVersionUID = 6600321365958270110L;

   public static final int TAMANHO_MAXIMO_NOME_City = 255;

   @Id
   @SequenceGenerator(name = "City_SEQ", sequenceName = "City_SEQ")
   @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "City_SEQ")
   @Column(name = "CDCity", nullable = false)
   private Long codigo;

   @Column(name = "NMCity", nullable = false, unique = true, length = City.TAMANHO_MAXIMO_NOME_City)
   private String nome;

   @ManyToOne(fetch = FetchType.LAZY)//
   @JoinColumn(name = "CDState", nullable = false)
   private State state;

   //...
}


When you press the 'CITY' no load 'State' but carrying its identifier.
example:

Code:
QUERY = 'SELECT city FROM City city'


City {
   codigo 1,
   nome 'test',
   State {
      codigo 100,
      nome null,
      nome2 null,
      nome3 null,
   }
}


Top
 Profile  
 
 Post subject: Re: doubts @ManyToOne
PostPosted: Tue Aug 20, 2013 3:03 pm 
Newbie

Joined: Mon Aug 19, 2013 10:14 am
Posts: 4
????????


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

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.