Link to home
Start Free TrialLog in
Avatar of roy_sanu
roy_sanuFlag for India

asked on

How to get value from the set Method

Can some body help me with the concept of   Set method in java with respect to database concept.

something like this
                
		Set<OrgUnitsLan> orgUnitsLan= .getOrgUnits()

Open in new window


The error it is showing in getOrgUnits ? let me know the concept of it.
Avatar of krakatoa
krakatoa
Flag of United Kingdom of Great Britain and Northern Ireland image

You’re not using a standard Java API on this call are you - so how is anyone going to know what the method is doing?
Please rephrase your question.

The concepts of set/get have nothing to do with Java or databases in general. They are a consequence of object oriented programming and from the encapsulation paradigm.

Private members of objects should only be accessed by methods to control that access for the purpose of validation, but also for keeping a correct state of an object. These methods are called setter and getter.

In Java and your sample, it seems that you're referencing an object of a class, which has a member OrgUnits - btw, pretty poor name. Thus you change the value by using the setOrgUnits(newValue) method and read by using the getOrgUnits() method.

Also you mentioning an error. What error, what exception message? Stack trace? Can you consider the simply mentioning an error does not provide enough information for us?

Thus: rephrase your question. Post a concise and complete example instead of fragments. Post the exact error or exception message. Consider posting the stack trace.
Avatar of roy_sanu

ASKER

Sir, when i am asking the concept let me know. I have not asked you the coding standard, please help me on it. I have a table called OrgUnitsLan as JPA call. I want to set in my current session as a database value which will be stored in the database table. How i should represent in java as I am new to java. This is Set method which has been already defined in JPA like Table and how to get the value. The setter and getter method already defined, Please refrain from looking at the coding standards.  
Thank you sir. Below is code base , please have a look. There are stored procedure wriitten to be called from java using Callable method.


Set<OrgUnitsLan> orgUnitsLan;
Sir, when i am asking the concept let me know.

I've explained the concept.

I have not asked you the coding standard, please help me on it.
I didn't write anything about coding standard. This would be for example the fact the the setter method in Java is named setOrgUnits instead of SetOrgUnits.

I have a table called OrgUnitsLan as JPA call.
This is a new piece of information, it wasn't part of your original post. JPA is a specific stack. This has nothing to do with concepts or general Java questions.

Below is code base
Nope, did not find anything of value. Code fragments do not help.

I asked you to post your actual error message or exception message. You have not posted the necessary and relevant information I've asked for.

THUS:  Rephrase your question. Include more details, preferably the exact context. Post a concise and complete example instead of fragments. Post the exact error or exception message. Consider posting the stack trace.
This i am setting Set<OrgUnitsLang> orgUnitsLang; and actual code is ready made one which i have asked you before, but let me know the where to find the solution if the expert exchange cannot tell me. The error i am getting is local variable may not be have been intialized.
i am passing something like this

X class method is calling y class method  let say X class of something(orgUnitsLang,temp) the calling method is Y class and Y is called some other class of X  Method of the other class. Tell me
why orgUnitsLang is telling "  local variable may not be have been intialized"
In this case, you'd be better, if you have a compiler error, to post your actual code, verbatim

The general concepts can be found in something like THIS
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.