• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Ranch Hand
Posts: 75
  • 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: 3497
39
  • 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.
 
Your mother was a hamster and your father was a tiny ad:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!