I have an SQL statement with the names of the class instead of the names of the tables.
Then I use a ResultTransformer to map the result in a bean, but Hibernate does not transform the query(with the classes) in a query capable for Oracle.
The code is like this:
Session sx = hibernateTemplate.getSessionFactory().openSession();
SQLQuery q = sx.createSQLQuery(queryUser);
sottoInterventiPagatiList = (List<SottoInterventiPagatiBean>)q.setResultTransformer(Transformers.aliasToBean(SottoInterventiPagatiBean.class)).list();
the query is:
select pagaSott.codiSequPagaSottInte as codiSequPagaSottInte,
pagaSott.impoSostSottInte as impoSostSottInte,
pagaSott.impoRichSottInte as impoRichSottInte,
pagaSott.impoAcceSottInte as impoAcceSottInte,
pagaSott.impoAmmeSottInte as impoAmmeSottInte,
pagaSott.codiSottTipo as codiSottTipo,
pagaInte.tabAgriPsrClTipoInt.codiTipo as codiTipo,
ammiDomaAiut.descSottTipo as descSottTipo,
ammiDomaAiut.impoSpesTotaAmme as impoSpesTotaAmme,
ammiDomaAiut.impoTotaAmme as impoTotaAmme
from AmmissibilitaDomandaAiuto ammiDomaAiut,
PagamentiDoma pagaDoma,
PagaInte pagaInte, PagaSottInte pagaSott
where pagaDoma.codiDomaAiut = ammiDomaAiut.domandaByCodiDomaAiut.codiDoma
and pagaDoma.tabAgriPsrClMisure.codiMisu = ammiDomaAiut.misure.codiMisu
and pagaInte.tabAgriPsrPagamentiDoma.codiSequPagaDoma = pagaDoma.codiSequPagaDoma
and pagaInte.tabAgriPsrClTipoInt.codiTipo = ammiDomaAiut.tipiIntervento.codiTipo
and pagaSott.tabAgriPsrPagaInte.codiSequPagaInte = pagaInte.codiSequPagaInte
and pagaSott.codiSottTipo = ammiDomaAiut.sottoTipiIntervento.codiSottTipo
and ammiDomaAiut.domandaByCodiDomaAiut.codiDoma = 13
and ammiDomaAiut.misure.codiMisu = 6
the bean is:
public class SottoInterventiPagatiBean implements Serializable{
private static final long serialVersionUID = -1831093835824406823L;
private Integer codiSequPagaSottInte;
private Integer codiTipo;
private BigDecimal codiSottTipo;
private String descSottTipo;
private BigDecimal impoSostSottInte;
private BigDecimal impoRichSottInte;
private BigDecimal impoAcceSottInte;
private BigDecimal impoAmmeSottInte;
private BigDecimal impoSpesTotaAmme;
private BigDecimal impoTotaAmme;
public Integer getCodiSequPagaSottInte() {
return codiSequPagaSottInte;
}
public void setCodiSequPagaSottInte(Integer codiSequPagaSottInte) {
this.codiSequPagaSottInte = codiSequPagaSottInte;
}
public Integer getCodiTipo() {
return codiTipo;
}
public void setCodiTipo(Integer codiTipo) {
this.codiTipo = codiTipo;
}
public BigDecimal getCodiSottTipo() {
return codiSottTipo;
}
public void setCodiSottTipo(BigDecimal codiSottTipo) {
this.codiSottTipo = codiSottTipo;
}
public String getDescSottTipo() {
return descSottTipo;
}
public void setDescSottTipo(String descSottTipo) {
this.descSottTipo = descSottTipo;
}
public BigDecimal getImpoSostSottInte() {
return impoSostSottInte;
}
public void setImpoSostSottInte(BigDecimal impoSostSottInte) {
this.impoSostSottInte = impoSostSottInte;
}
public BigDecimal getImpoRichSottInte() {
return impoRichSottInte;
}
public void setImpoRichSottInte(BigDecimal impoRichSottInte) {
this.impoRichSottInte = impoRichSottInte;
}
public BigDecimal getImpoAcceSottInte() {
return impoAcceSottInte;
}
public void setImpoAcceSottInte(BigDecimal impoAcceSottInte) {
this.impoAcceSottInte = impoAcceSottInte;
}
public BigDecimal getImpoAmmeSottInte() {
return impoAmmeSottInte;
}
public void setImpoAmmeSottInte(BigDecimal impoAmmeSottInte) {
this.impoAmmeSottInte = impoAmmeSottInte;
}
public BigDecimal getImpoSpesTotaAmme() {
return impoSpesTotaAmme;
}
public void setImpoSpesTotaAmme(BigDecimal impoSpesTotaAmme) {
this.impoSpesTotaAmme = impoSpesTotaAmme;
}
public BigDecimal getImpoTotaAmme() {
return impoTotaAmme;
}
public void setImpoTotaAmme(BigDecimal impoTotaAmme) {
this.impoTotaAmme = impoTotaAmme;
}
}
Use session.createQuery(...) instead of createSQLQuery(...). createSQLQuery creates an SQL query, hibernate assumes that your query is already in sql format, then no other transformation is done.
Related
I am doing a liferay project which use ejb at back end. so my ejb method looks like this:-
#Override
public List<RmisPaymentDetailsDto> getEpaymentDetails(String ebpCode) {
Query q = entityManager.createQuery("select s from EpaymentBo s where s.ebpCode=:ebpcode")
.setParameter("ebpcode",ebpCode);
#SuppressWarnings("unchecked")
List<ProductBo> list = q.getResultList();
Iterator<ProductBo> i = list.iterator();
List<RmisPaymentDetailsDto> rList = new ArrayList<RmisPaymentDetailsDto>();
while(i.hasNext()){
EpaymentBo ep =(EpaymentBo) i.next();
RmisPaymentDetailsDto dto = new RmisPaymentDetailsDto();
dto.setAdvertisementcode(ep.getAdvertisementcode());
dto.setAmount(ep.getAmount());
dto.setStudentmasterid(ep.getStudentmasterid());
dto.setEbpgendate(ep.getEbp_gen_date());
dto.setEbpcode(ep.getEbpCode());
dto.setPaymentstatus(ep.getPaymentstatus());
dto.setCandidatenameinnepali(ep.getCandidatenameinnepali());
rList.add(dto);
}
return rList;
}
the above method successfully fetches data from database and sets it to my RmisPaymentDetailsDto.
like this:-
now i am calling same method from my liferay controlller.
PreExaminationRemote preRef = (PreExaminationRemote) jndiContext
.lookup("PreExamination/remote");
List<RmisPaymentDetailsDto> rDto = preRef.getEpaymentDetails(ebpCode);
I am wondering how my one property(candidatenameinnepali) is lost as i return same dto from my ejb.
My dto looks like this:-
public class RmisPaymentDetailsDto implements Serializable {
private static final long serialVersionUID = 1L;
private String advertisementcode;
private String ebpcode;
private String amount;
private String studentmasterid;
private Date ebpgendate;
private String paymentstatus;
private String candidatenameinnepali;
public String getCandidatenameinnepali() {
return candidatenameinnepali;
}
public void setCandidatenameinnepali(String candidatenameinnepali) {
this.candidatenameinnepali = candidatenameinnepali;
}
public String getAdvertisementcode() {
return advertisementcode;
}
public void setAdvertisementcode(String advertisementcode) {
this.advertisementcode = advertisementcode;
}
public String getEbpcode() {
return ebpcode;
}
public void setEbpcode(String ebpcode) {
this.ebpcode = ebpcode;
}
public String getAmount() {
return amount;
}
public void setAmount(String amount) {
this.amount = amount;
}
public String getStudentmasterid() {
return studentmasterid;
}
public void setStudentmasterid(String studentmasterid) {
this.studentmasterid = studentmasterid;
}
public Date getEbpgendate() {
return ebpgendate;
}
public void setEbpgendate(Date ebpgendate) {
this.ebpgendate = ebpgendate;
}
public String getPaymentstatus() {
return paymentstatus;
}
public void setPaymentstatus(String paymentstatus) {
this.paymentstatus = paymentstatus;
}
public static long getSerialversionuid() {
return serialVersionUID;
}
}
I am experiencing strange behavior. I am using hibernate. I have two tables.
#Entity
public class Nemocnica implements java.io.Serializable {
#Id
#GeneratedValue(strategy=GenerationType.IDENTITY)
#Column(name="N_ID")
private BigDecimal NId;
#Column(name="adresa")
private String adresa;
#OneToMany
private Set sanitkas = new HashSet(0);
public Nemocnica() {
}
public Nemocnica( String adresa) {
this.NId = NId;
}
public Nemocnica(BigDecimal NId, String adresa) {
this.NId = NId;
this.adresa = adresa;
}
public Nemocnica(BigDecimal NId, String adresa, Set sanitkas) {
this.NId = NId;
this.adresa = adresa;
this.sanitkas = sanitkas;
}
public BigDecimal getNId() {
return this.NId;
}
public void setNId(BigDecimal NId) {
this.NId = NId;
}
public String getAdresa() {
return this.adresa;
}
public void setAdresa(String adresa) {
this.adresa = adresa;
}
public Set getSanitkas() {
return this.sanitkas;
}
public void setSanitkas(Set sanitkas) {
this.sanitkas = sanitkas;
}
}
and second
#Entity
public class Sanitka implements java.io.Serializable {
private BigDecimal sanitkaId;
private transient Nemocnica nemocnica;
private BigDecimal kapacita;
#ManyToOne
#JoinColumn(name="nemocnica_n_id")
private Set sanitaris = new HashSet(0);
public Sanitka() {
}
public Sanitka(BigDecimal sanitkaId, Nemocnica nemocnica, BigDecimal kapacita) {
this.sanitkaId = sanitkaId;
this.nemocnica = nemocnica;
this.kapacita = kapacita;
}
public Sanitka(BigDecimal sanitkaId, Nemocnica nemocnica, BigDecimal kapacita, Set sanitaris) {
this.sanitkaId = sanitkaId;
this.nemocnica = nemocnica;
this.kapacita = kapacita;
this.sanitaris = sanitaris;
}
public BigDecimal getSanitkaId() {
return this.sanitkaId;
}
public void setSanitkaId(BigDecimal sanitkaId) {
this.sanitkaId = sanitkaId;
}
#ManyToOne(cascade=CascadeType.ALL)
public Nemocnica getNemocnica() {
return this.nemocnica;
}
public void setNemocnica(Nemocnica nemocnica) {
this.nemocnica = nemocnica;
}
public BigDecimal getKapacita() {
return this.kapacita;
}
public void setKapacita(BigDecimal kapacita) {
this.kapacita = kapacita;
}
public Set getSanitaris() {
return this.sanitaris;
}
public void setSanitaris(Set sanitaris) {
this.sanitaris = sanitaris;
}
}
And routes that mannipulate with them.
nemocnicaRoute:
#Path("nemocnica")
public class nemocnicaRoute {
// private static final helper db = new helper();
#GET
#Path("all")
#Produces(MediaType.APPLICATION_JSON)
public String getName(){
List<Nemocnica> l = db.helper.getNemocnicas();
GsonBuilder builder = new GsonBuilder();
Gson gson = builder.create();
//System.out.println( json );
//return l.toString();
return gson.toJson(l);
}
// another methods
}
sanitkaRoute
#Path("sanitka")
public class sanitkaRoute {
//private static final helper db = new helper();
#GET
#Path("all")
#Produces("text/plain")
public String getName(){
List<Sanitka> l = db.helper.getSanitkas();
GsonBuilder builder = new GsonBuilder();
Gson gson = builder.create();
//System.out.println( json );
//return l.toString();
return gson.toJson(l);
}
// another methods
}
I am using these two getName() methods to retrieve all data from said tables.
This cause strange behavior , if i invoke get request on nemocnicaRoute first , it works very well as it should.
However when i invoke get requet on sanitkaRoute first , it works but after that when i want to invoke get request on nemocniceRoute it throws
java.lang.UnsupportedOperationException: Attempted to serialize
java.lang.Class: org.hibernate.proxy.HibernateProxy. Forgot to
register a type adapter?
Which confuses me , bcs this does not happen when i invoke getRequest on nemocnicaRoute first.
How could i fix this strange behavior?
All help appreciated
I want to get my profile in class Tournee (profil_tournee) list based on my tours ("tournee"). However, I have an exception. Can anyone help me?
Exception in thread "AWT-EventQueue-0"
java.lang.IllegalArgumentException: Type specified for TypedQuery
[fr.galettedebroons.domain.Profil] is incompatible with query return
type [interface java.util.Collection]
Request:
List<List<Profil>> listProfil = Arrays.asList(manager_.createQuery("select t.profil_tournee "
+ "FROM Tournee t WHERE t.nom LIKE :tournee", Profil.class)
.setParameter("tournee", tournee)
.getResultList());
Model :
#Entity
public class Tournee {
private int id;
private String nom;
private boolean lundi = false;
private boolean mardi = false;
private boolean mercredi = false;
private boolean jeudi = false;
private boolean vendredi = false;
private boolean samedi = false;
private boolean dimanche = false;
private List<Profil> profil_tournee;
public Tournee(){}
public Tournee(String nom, boolean lundi, boolean mardi, boolean mercredi, boolean jeudi,
boolean vendredi, boolean samedi, boolean dimanche, List<Profil> profil_tournee) {
this.nom = nom;
this.lundi = lundi;
this.mardi = mardi;
this.mercredi = mercredi;
this.jeudi = jeudi;
this.vendredi = vendredi;
this.samedi = samedi;
this.dimanche = dimanche;
this.profil_tournee = profil_tournee;
}
public Tournee(String nom, boolean lundi, boolean mardi, boolean mercredi, boolean jeudi,
boolean vendredi, boolean samedi, boolean dimanche) {
this.nom = nom;
this.lundi = lundi;
this.mardi = mardi;
this.mercredi = mercredi;
this.jeudi = jeudi;
this.vendredi = vendredi;
this.samedi = samedi;
this.dimanche = dimanche;
}
#Id #GeneratedValue(strategy = GenerationType.AUTO)
public int getId() {
return id;
}
public void setId(int id_tournee) {
this.id = id_tournee;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public boolean isLundi() {
return lundi;
}
public void setLundi(boolean lundi) {
this.lundi = lundi;
}
public boolean isMardi() {
return mardi;
}
public void setMardi(boolean mardi) {
this.mardi = mardi;
}
public boolean isMercredi() {
return mercredi;
}
public void setMercredi(boolean mercredi) {
this.mercredi = mercredi;
}
public boolean isJeudi() {
return jeudi;
}
public void setJeudi(boolean jeudi) {
this.jeudi = jeudi;
}
public boolean isVendredi() {
return vendredi;
}
public void setVendredi(boolean vendredi) {
this.vendredi = vendredi;
}
public boolean isSamedi() {
return samedi;
}
public void setSamedi(boolean samedi) {
this.samedi = samedi;
}
public boolean isDimanche() {
return dimanche;
}
public void setDimanche(boolean dimanche) {
this.dimanche = dimanche;
}
#OneToMany(mappedBy="profil_tournee", cascade=CascadeType.PERSIST)
public List<Profil> getProfil_tournee() {
return profil_tournee;
}
public void setProfil_tournee(List<Profil> profil_tournee) {
this.profil_tournee = profil_tournee;
}
}
#Entity
public class Profil {
private String code_client;
private Client client_profil;
private Gamme gamme_profil;
private List<Livraison> livraison_profil;
private Boolean actif;
private Tournee profil_tournee;
private List<MargeLivraison> marge_profil;
private List<Prevision> prevision_profil;
public Profil(){}
public Profil(Gamme code_gamme, List<Livraison> livraison, Boolean actif) {
this.gamme_profil = code_gamme;
this.livraison_profil = livraison;
this.actif = actif;
}
#Id
public String getCode_client() {
return code_client;
}
public void setCode_client(String code_client) {
this.code_client = code_client;
}
public Boolean getActif() {
return actif;
}
public void setActif(Boolean actif) {
this.actif = actif;
}
#ManyToOne
public Gamme getGamme_profil() {
return gamme_profil;
}
public void setGamme_profil(Gamme gamme_profil) {
this.gamme_profil = gamme_profil;
}
#OneToMany(mappedBy="livraison_profil", cascade=CascadeType.PERSIST)
public List<Livraison> getLivraison_profil() {
return livraison_profil;
}
public void setLivraison_profil(List<Livraison> livraison_profil) {
this.livraison_profil = livraison_profil;
}
#ManyToOne
public Client getClient_profil() {
return client_profil;
}
public void setClient_profil(Client client) {
this.client_profil = client;
}
#ManyToOne
public Tournee getProfil_tournee() {
return profil_tournee;
}
public void setProfil_tournee(Tournee profil_tournee) {
this.profil_tournee = profil_tournee;
}
#OneToMany(mappedBy="marge_profil", cascade=CascadeType.PERSIST)
public List<MargeLivraison> getMarge_profil() {
return marge_profil;
}
public void setMarge_profil(List<MargeLivraison> marge_profil) {
this.marge_profil = marge_profil;
}
#OneToMany(mappedBy="prevision_profil", cascade=CascadeType.PERSIST)
public List<Prevision> getPrevision_profil() {
return prevision_profil;
}
public void setPrevision_profil(List<Prevision> prevision_profil) {
this.prevision_profil = prevision_profil;
}
Your expected result list will contain elements that are list of profiles, not profiles.
I would replace Profil.class by List.class for the Query creation :
List<List<Profil>> listProfil = Arrays.asList(manager_.createQuery("select t.profil_tournee "
+ "FROM Tournee t WHERE t.nom LIKE :tournee", List.class)
.setParameter("tournee", tournee)
.getResultList());
Your error gives you a hint that the returning type should be consistent with declared type when invoking EntityManager.createQuery(query, Type) method:
List<SomeType> em.createQuery("SELECT s FROM SomeType", SomeType.class);
However your real problem is that your query is illegal. In JPA collection-valued expressions cannot be part of SELECT clause. Please see another answer of mine https://stackoverflow.com/a/25890863/3796586.
The solution in your case would be to reverse the query like this:
List<Profil> result = em.createQuery("SELECT p FROM Profil p WHERE" +
"p.profil_tournee.norm LIKE :tournee", Profil.class)
.setParameter("tournee", tournee)
.getResultList());
I am using following query
String queryString = "select NEW com.h.offering.dto.SellerDetailsDto(p.productId,p.sellerId, p.sellerSku, p.sellPrice, " +
"p.transferPrice, p.sellerMRP,p.aCommission,p.baseShippingFee,p.addnShippingFee, " +
"p.propogationLevel,p.propogationValue,a.warehouseName,a.quantity,a.maxShippingTime,a.minShippingTime) "
+ "from PriceDetails p, AvailabilityDetails a "
+ "where a.productId = p.productId "
+ "and a.sellerSku = p.sellerSku "
+ "and a.sellerId = :sellerId";
while executing i am getting error
org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor on class [com.a.offering.dto.SellerDetailsDto] [select NEW com.s.offering.dto.SellerDetailsDto(p.productId) from com.a.offering.db.domain.PriceDetails p, com.a.offering.db.domain.AvailabilityDetails a where a.productId = p.productId and a.sellerSku = p.sellerSku and a.sellerId = :sellerId]
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:54)
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:47)
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:82)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:261)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
and so on...
I am unable to figure out the error. Help me out
The code for SellerDetailsDto.java is
package com.a.offering.dto;
public class SellerDetailsDto {
public String productId;
public String sellerId;
public String sellerSku;
public Double sellPrice;
public Double transferPrice;
public Double sellerMRP;
public Double a;
public Double baseShippingFee;
public Double addnShippingFee;
public String propogationLevel;
public String propogationValue;
public String warehouseName;
public int quantity;
public int maxShippingTime;
public int minShippingTime;
public String getProductId() {
return productId;
}
public void setProductId(String productId) {
this.productId = productId;
}
public String getSellerId() {
return sellerId;
}
public void setSellerId(String sellerId) {
this.sellerId = sellerId;
}
public String getSellerSku() {
return sellerSku;
}
public void setSellerSku(String sellerSku) {
this.sellerSku = sellerSku;
}
public String getWarehouseName() {
return warehouseName;
}
public void setWarehouseName(String warehouseName) {
this.warehouseName = warehouseName;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public int getMaxShippingTime() {
return maxShippingTime;
}
public void setMaxShippingTime(int maxShippingTime) {
this.maxShippingTime = maxShippingTime;
}
public int getMinShippingTime() {
return minShippingTime;
}
public void setMinShippingTime(int minShippingTime) {
this.minShippingTime = minShippingTime;
}
public Double getSellPrice() {
return sellPrice;
}
public void setSellPrice(Double sellPrice) {
this.sellPrice = sellPrice;
}
public Double getTransferPrice() {
return transferPrice;
}
public void setTransferPrice(Double transferPrice) {
this.transferPrice = transferPrice;
}
public Double getSellerMRP() {
return sellerMRP;
}
public void setSellerMRP(Double sellerMRP) {
this.sellerMRP = sellerMRP;
}
public Double a() {
return a;
}
public void a(Double aa) {
a }
public Double getBaseShippingFee() {
return baseShippingFee;
}
public void setBaseShippingFee(Double baseShippingFee) {
this.baseShippingFee = baseShippingFee;
}
public Double getAddnShippingFee() {
return addnShippingFee;
}
public void setAddnShippingFee(Double addnShippingFee) {
this.addnShippingFee = addnShippingFee;
}
public String getPropogationLevel() {
return propogationLevel;
}
public void setPropogationLevel(String propogationLevel) {
this.propogationLevel = propogationLevel;
}
public String getPropogationValue() {
return propogationValue;
}
public void setPropogationValue(String propogationValue) {
this.propogationValue = propogationValue;
}
}
Hibernate needs a constructor with at least package private (i. e. default) visibility.
Normally a parameterless constructor is necessary (which you implicitly have), but for your select new ... SellerDetailsDto needs a constructor with the 15 parameters which you give in the select statement. (Thought the error message demands a constructor with only the id as a parameter - it looks like if the error is coming from a different select new statement.) You don't have such a constructor.
The problem is that you don't have a constructor in SellerDetailsDto that accepts the parameters that you are passing in the hql query. Add this constructor to your class:
public SellerDetailsDto(String productId, String sellerId,
String sellerSku, Double sellPrice, Double transferPrice,
Double sellerMRP, Double tradusCommission, Double baseShippingFee,
Double addnShippingFee, String propogationLevel,
String propogationValue, String warehouseName, int quantity,
int maxShippingTime, int minShippingTime) {
this.productId = productId;
this.sellerId = sellerId;
this.sellerSku = sellerSku;
this.sellPrice = sellPrice;
this.transferPrice = transferPrice;
this.sellerMRP = sellerMRP;
this.tradusCommission = tradusCommission;
this.baseShippingFee = baseShippingFee;
this.addnShippingFee = addnShippingFee;
this.propogationLevel = propogationLevel;
this.propogationValue = propogationValue;
this.warehouseName = warehouseName;
this.quantity = quantity;
this.maxShippingTime = maxShippingTime;
this.minShippingTime = minShippingTime;
}
This could make some other code you have to stop working, because now there wont' be a default constructor available. To fix that, add a default constructor too:
public SellerDetailsDto() {}
Actually this is problem on your root pom file. You want install lombok in your IDE & add dependency of lombok in root pom file I hope it will work
I need to design a report, that displays the data from a collection(Say List). This list contains multiple POJOs.
The POJOs are populated by the data access layer of the application. How do I design a report template for this requirement in iReports?
Use JRBeanCollectionDataSource for your report.
Ok! Found the answer. The steps are as below.
Compile the bean classes and create a JAR file. This needs to have the complete package
Add this jar to the LIB folder in ireports
Create a factory/wrapper class that has a createBeanCollection method that populates a collection
Use this class's top level package as the class path in ireports
Use this class as the JavaBean datasource with the method.
Once all this is done, create a report with the new datasource and in report query, give the FQN on the Java bean and add the desired field.
BankDetailsList list = new BankDetailsList();
ArrayList<BankDetails> lst = list.getDataBeanList();
JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(lst);
Here BankDetails is a POJO
public class BankDetails {
public String bank_name;
public Account account;
public String custodian_account;
public String custodian_name;
public String agreement_type;
public double exposure;
public double collateral;
public double independant_amount;
public double net_exposure;
BankDetails(String b_name, Account acc, String cust_account,
String cust_name, String agr_type, double expo, double collat,
double independant_amt, double net_exp) {
this.bank_name = b_name;
this.account = acc;
this.custodian_account = cust_account;
this.custodian_name = cust_name;
this.agreement_type = agr_type;
this.exposure = expo;
this.collateral = collat;
this.independant_amount = independant_amt;
this.net_exposure = net_exp;
}
public String getBank_name() {
return bank_name;
}
public void setBank_name(String bank_name) {
this.bank_name = bank_name;
}
public Account getAccount() {
return account;
}
public void setAccount(Account account) {
this.account = account;
}
public String getCustodian_account() {
return custodian_account;
}
public void setCustodian_account(String custodian_account) {
this.custodian_account = custodian_account;
}
public String getCustodian_name() {
return custodian_name;
}
public void setCustodian_name(String custodian_name) {
this.custodian_name = custodian_name;
}
public String getAgreement_type() {
return agreement_type;
}
public void setAgreement_type(String agreement_type) {
this.agreement_type = agreement_type;
}
public double getExposure() {
return exposure;
}
public void setExposure(double exposure) {
this.exposure = exposure;
}
public double getCollateral() {
return collateral;
}
public void setCollateral(double collateral) {
this.collateral = collateral;
}
public double getIndependant_amount() {
return independant_amount;
}
public void setIndependant_amount(double independant_amount) {
this.independant_amount = independant_amount;
}
public double getNet_exposure() {
return net_exposure;
}
public void setNet_exposure(double net_exposure) {
this.net_exposure = net_exposure;
}
}
Account POJO:
public class Account {
public int account_id;
public String account_name;
Account(int acc_id, String acc_name){
this.account_id = acc_id;
this.account_name = acc_name;
}
public int getAccount_id() {
return account_id;
}
public void setAccount_id(int account_id) {
this.account_id = account_id;
}
public String getAccount_name() {
return account_name;
}
public void setAccount_name(String account_name) {
this.account_name = account_name;
}
}