Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setters/Getters

 
Premila Devi Dayalan
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Sir,

I'm a little less certain about exactly how these getters and setters will interact with all the various field types [Tecnically].

This patch adds a 'getter' and 'setter' attribute to all fields, which takes a string of a method to call when a field is retrieved or set.

This defines a getter returns a filtered value from the DB, a setter processes the value to add "_setter" to it in all cases, and on has_both we see a setter than implements the use case of updating another field when a property is set.


Example: We set the cam.model value as "TVM4" in the database and, when we intended to get the value from the database it will return as "TVM4"as well.A getter receives as its argument the current "real" value (the one that either came from the database, object construction, or a prior setting of the value), and what the getter returns is actually what the user gets back from the attribute.Please guide,me,hoe the setter and getters integrated with database with an Example.
.

A setter receives as its argument the value that the user is setting the property to, and what it returns is what the property will actually be set to.

Getters and setters do not operate during the creation of the object, but by retrieval from the database or creation by instantiating the class; Please advise.

Please correct me,if I am wrong.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the context here? Are you asking about a specific ORM product?
 
Premila Devi Dayalan
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What mainly "Setter" and "Getter" did,in the Specification of Java.

Thanks.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I am aware, the Java language specifications doesn't mention getters or setters anywhere. Where did your quotes come from?
 
Premila Devi Dayalan
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Sir,

Example:



** getOwner [getter] and setOwner [setter]


Thanks.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I know what getters and setters are, what I don't understand is your question:

Getters and setters do not operate during the creation of the object, but by retrieval from the database or creation by instantiating the class; Please advise

A little more context would help us understand what you are asking.
 
Premila Devi Dayalan
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Sir,

These sentences,I am not very sure,It was right or wrong,do I am asking your suggesstions sir?
Getters and setters do not operate during the creation of the object, but by retrieval from the database or creation by instantiating the class;



Question:
1.I like to know,how setter and getter integrated with database,Technically,how the are integrated the data as per requested.
I know that mainly,we something as "ABC",and ask the machine to the value of the "ABC",that we already ,defaultly.

2.At here,I like to know,techically,how it work sir.

Thanks.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

1.I like to know,how setter and getter integrated with database,Technically,how the are integrated the data as per requested.

There is no integration between a getter/setter and the database, that is unless you are using an ORM tool.

 
Premila Devi Dayalan
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Sir,

I am using Object-relational_mapping (ORM) tools here sir.

Thanks.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which one? Is that where your quotes come from?
 
Premila Devi Dayalan
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Sir,

Referring to these code:



How it is integrated with database sir,using ORM.Just for my undestanding itself.

Just a basic ideas sir.

Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic