Solved

Have custom function in a EJB

Posted on 2009-07-01
6
311 Views
Last Modified: 2013-11-24
Hi,

I've a integer field in the database, that represent a status. I want to display a text instead of this textField. So I've added a function called

public getTextStatus(){
....
}

But when I do this, I've this error:
Caused by: javax.el.PropertyNotFoundException: The class 'datamodel.Deal' does not have the property 'TextStatus'.


After this I've tried to add a fake EJB field and I've now this error.
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'TEXTSTATUS' in 'field list'

I understand theses errors but I don't know how to bypass them.

Why generating this in the EJB? Because I need to display it in a table, (rich:datatable), and I was thinking it was the easier way.

Have you an idea?

Thanks!
0
Comment
Question by:Nargzul
  • 3
  • 3
6 Comments
 
LVL 3

Expert Comment

by:serrutom
ID: 24754941
Did you add this function to your interface class?
0
 
LVL 1

Author Comment

by:Nargzul
ID: 24755020
Not really, because the EJB itself doesn't have an interface.

I've added this function to the entity, and after I use a session bean to access it(and this session bean has interfaces)
0
 
LVL 3

Accepted Solution

by:
serrutom earned 500 total points
ID: 24755977
If you want to add a getter to you EJB class that should not be persisted to the database you should add the @Transient annotation.

@Transient
public String getTextStatus() {
   ...
}

In you JSF page, did you use TextStatus or textStatus? The first letter of the property should be lower case in your JSF pages, and the error displays a capital T.

Can you post some code?
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 1

Author Comment

by:Nargzul
ID: 24845072
When I add the @Transient before my getter, I got one error from netbeans, saying me the "There is no ID defined for this entity hierarchy"


I don't really know what changed, but now, without properties, only with a getter, it works.

It's maybe the Maj problem as you said. Thanks you for your help.
0
 
LVL 3

Expert Comment

by:serrutom
ID: 24846941
Was your property private or public?

If you have a public property, i think it will also be available and persisted.
0
 
LVL 1

Author Comment

by:Nargzul
ID: 24849164
I wasn't having a property, only getters and setters,

In fact the getter only take a String in an array, depending of the value of a persistent field.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
split53 challenge 7 96
firstswap challenge 20 77
maven project error 5 55
rhino JavaScript import, load 25 84
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question