Jump to content
Changes to the Jaspersoft community edition download ×

Hibernate Question

2004 IR Help

Recommended Posts

By: mattism - mattism

Hibernate Question

2005-09-27 12:07

I need to use a method from the hibernate object that I have passed into my jrxml file but I can not figure out exactly how to do this. I have been able to access a method from an object withing an object bu I cant figure out getting the method from just the single object here is an example.


I have been able to get a method from an object with in an object

hence CSCR contains object Ally

I declared ally as type object then did the

((mil.biz.ally.Ally)$F{ally} ).getAllyIdentifier() and I get what I expected.


I need the getCscrIdentifier() method from my CSCR object. I tried doing it like I was getting a method from another object but cscr is not a field that I can use. I though maybe I could do it as a variable but I just got all nulls. Can anyone help me with this? Am I overlooking something simple? Thanks for the help.







By: mattism - mattism

RE: Hibernate Question

2005-09-27 13:50

Well I was able to figue it out. I was able to access it by declaring field cscrIdentifier as a string and then using it.







By: gabiB - gabib

RE: Hibernate Question

2005-10-04 06:24


I need to do something like what you did, but I don´t know how to access hibernate objects inside jasper. I don´t know how to declare the classes.

Could you tell me how you have done that?

Thank you






By: David Heffelfinger - heffel

RE: Hibernate Question

2005-10-04 06:47



You can pass a collection or array of POJOs (Plain Old Java Objects) as a datasource to your report. This works as long as your POJOs comply with the JavaBeans specification (the only requirements are: no public fields, a no argument constructor, and access to the private fields must be through getters and setters).


You can see a brief tutorial at http://www.hibernate.org/79.html


Hope that helps,






By: gabiB - gabib

RE: Hibernate Question

2005-10-04 12:14

I have already read that tutorial. I have already made what is said ther. But my problem is at jasper. Or problems.

My first problem: the object I need in the report has some fields which are other objects, which have

fields that are objects and so on. I don´t know how to access all these fields inside JasperReport.


My second problem: I need to use subreports. I don´t know what parameters I use in the subreports. But I think as long as I find out how to solve problem number 1, I will get along with number 2.


Thank you very much for your quick answer, David.





By: Kolesnikov Alexey - kolesnikov

RE: Hibernate Question

2005-11-14 14:02



Did you solve this problem? Actually I'm using JasperReports with Hibernate and sometimes I need to get properties like in your first problem.

I'm using custom datasource based on JRDataSource and little trick in getFieldValue:


public Object getFieldValue(JRField field) throws JRException {

try {

String fieldName = field.getName().replaceAll("_", ".");

return PropertyUtils.getNestedProperty(currentValue, fieldName);

} catch (Exception ex) {

throw new JRException(ex);




So, if you need to get obj1.obj2.prop1 property just use $F{obj1_obj2_prop1} in report.


Hope this helps.


Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...