• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

Trying to use inner join in my class but it throws error  RSS feed

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am using hibernate to connect to my DB and retrieve the records. Basically I am trying to run the below query in my java class.



But Im getting below exception. Please throw some light on this. Thanks !!!



public class Billing_Cons_Producer_Assoc {
   
   @OneToMany
   @JoinColumn(name="BILLING_CONS_ID")
   private BillingConsolidation BILLING_CONS_ID;
   @Id
   private String BRANCH_CD;
   @Id
   private String PRODUCER_CD;
   @Column(nullable=true)
   private String MASTER_IND;
   @Column(nullable=true)
   private java.sql.Date CREATED_DT;
   @Column(nullable=true)
   private int INACTIVE_IND;
   @Column(nullable=true)
   private String GEN_ID;
 
public class BillingConsolidation {
   
   @Id
   private String BILLING_CONS_ID;
   private String BILLING_CONS_NAM;
   private java.util.Date CREATED_DT;
   private int ACTIVE_ROW_IND;
   private int PAPERLESS_IND;
   private java.util.Date UPDATED_DT;
   private int DB_COMM_STMT_IND;
   private int DB_COMM_PYMT_IND;
   private int JPMC_SETUP_IND;
   private String BANK_ACCT_NBR;
   private String BANK_ROUTING_NBR;
   private String UPDATED_USER_ID;
   private int GEN_ID;
   private int DB_AGENT_COMBO_IND;
   private int EANDO_PAPERLESS_IND;
   private int EANDO_EMAIL_IND;
   private int DB_PAPERLESS_IND;
   private int DB_PAYGO_SPRT_CHECK_IND;
   private int WCP_STMT_IND;
   private int DB_STMT_IND;
   private int AGENT_STMT_IND;

public class TestingService {


   public static void main(String args[]){
SessionFactory factory =
   new Configuration().configure("hibernate.cfg.xml").buildSessionFactory();
Billing_Cons_Producer_Assoc obj = new Billing_Cons_Producer_Assoc();
Session session = factory.openSession();

Query query = session.createQuery("select * from Billing_Cons_Producer_Assoc c inner join "
+ "Billing_Consolidation b on B.Billing_Cons_Id=C.Billing_Cons_Id ");
       ArrayList a = (ArrayList) query.list();
       System.out.println(a.size());
factory.close();


   }
   
   


 
Rancher
Posts: 3931
45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

That says that you should have many BillingConsolidations, but you are only mapping it to a single BillingConsolidation.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!