This week's book giveaway is in the Artificial Intelligence forum.
We're giving away four copies of Pragmatic AI and have Noah Gift on-line!
See this thread for details.
Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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

 
Ranch Hand
Posts: 83
  • 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: 3602
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!