-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
possible bug with insert operation #95
Comments
This is a very interesting issue. Part of it is because of the field names and how IDEs are generating the setter/getter methods. If a field name is Catatumbo is looking for Same applies to your field - Java's own API (JavaBeans) - Code from Java's PropertyDescriptor
Now, the JavaBeans Introspector works differently and matches with the IDE's behavior. Sample Code
Output
The threads below are worth taking a look at: http://stackoverflow.com/questions/2948083/naming-convention-for-getters-setters-in-java http://stackoverflow.com/questions/15115072/how-to-identify-setter-method-using-property-name That said - I do feel like Catatumbo needs to be fixed to be compatible with the IDEs, so I will go ahead and provide a fix. |
Thinking more on this - I'm not sure what is really correct. I feel like the JavaBeans framework itself is broke based on the sample code I've posted. PropertyDescriptor expects a different method than what the Introspector finds. Any of the watchers have any thoughts to share?? |
The fix (to be compatible with IDE generated accessor methods) would be changing the
I will check in this code soon with test cases, if I don't get any further feedback. @atfreddos - can you possibly clone the repo and make the above change and see if your entities get mapped correctly? |
Hi Sai, ok will do shortly. I found a discussion of the issue here, it may be of help or interest: |
Hi Sai, |
@atfreddos - Version 1.1.3 should be available in Maven Central in a few hours. This release contains the fix for this issue. Thanks for reporting! |
C:\Program Files\Google\Cloud SDK2>gcloud -v
Google Cloud SDK 136.0.0
app-engine-java 1.9.46
cloud-datastore-emulator 1.2.1
core 2016.11.30
core-win 2016.11.07
gcloud
Catatumbo version 1.1.1
Windows 7
Eclipse Mars,
JRE System Library [JavaSE 1.8] Oracle
Insert problem. The logical requirement for an insert is that the database entity inserted is exactly the same as the entity presented to the database. In the example below, the input fields aRUserId=arcathy, aRLoginName=maskedman have been set to null in the Local Datastore. I have not used all fields in the class.
The problem in steps:
Step 1.
Connect to Local Datastore
INFO: Datastore Environment Host = localhost:8426 ProjectID = ds1-test
INFO: DSConnect: Datastore Connection created.
Step 2.
Create an example class 'userbean1'
INFO: created: UserAccountSessionBean [id=null, userId=Zorro, aRUserId=arcathy, aRLoginName=maskedman, uniqueId=arcathy-2, uuid=mdmdmdmdmdmdmdmd, firstName=fred, lastName=smith, fullName=fred smith, email=null, admin=false, ip=null, channelId=null, websocketEndpointURI=null, sessionID=null, issuedAt=null, expiration=null, lastActive=null, lastLoginOn=null, lastReported=null, lastPage=null, tK=null]
Step 3.
Using Data Access Object, try to save 'userbean1' into Local Datastore
DAO IN > SAVE: userBean1: UserAccountSessionBean [id=null, userId=Zorro, aRUserId=arcathy, aRLoginName=maskedman, uniqueId=arcathy-2, uuid=mdmdmdmdmdmdmdmd, firstName=fred, lastName=smith, fullName=fred smith, email=null, admin=false, ip=null, channelId=null, websocketEndpointURI=null, sessionID=null, issuedAt=null, expiration=null, lastActive=null, lastLoginOn=null, lastReported=null, lastPage=null, tK=null]
Step 3(i) Perform actual insert: (actual method called: 'UserAccountSessionBean sbean = DSConnect.INSTANCE.em().insert( bean );')
Precondition : Inserting object:UserAccountSessionBean [id=null, userId=Zorro, aRUserId=arcathy, aRLoginName=maskedman, uniqueId=arcathy-2, uuid=mdmdmdmdmdmdmdmd, firstName=fred, lastName=smith, fullName=fred smith, email=null, admin=false, ip=null, channelId=null, websocketEndpointURI=null, sessionID=null, issuedAt=null, expiration=null, lastActive=null, lastLoginOn=null, lastReported=null, lastPage=null, tK=null]
call .insert( userbean1 )
Postcondition: Insert returns:UserAccountSessionBean [id=38, userId=Zorro, aRUserId=null, aRLoginName=null, uniqueId=arcathy-2, uuid=mdmdmdmdmdmdmdmd, firstName=fred, lastName=smith, fullName=fred smith, email=null, admin=false, ip=null, channelId=null, websocketEndpointURI=null, sessionID=null, issuedAt=null, expiration=null, lastActive=null, lastLoginOn=null, lastReported=null, lastPage=null, tK=null]
DAO OUT < SAVE: userBean1: UserAccountSessionBean [id=38, userId=Zorro, aRUserId=null, aRLoginName=null, uniqueId=arcathy-2, uuid=mdmdmdmdmdmdmdmd, firstName=fred, lastName=smith, fullName=fred smith, email=null, admin=false, ip=null, channelId=null, websocketEndpointURI=null, sessionID=null, issuedAt=null, expiration=null, lastActive=null, lastLoginOn=null, lastReported=null, lastPage=null, tK=null]
Step 4.
Get (load) saved (inserted) object using Id=38
DATASTORE ENTRY userBean1 by id =
UserAccountSessionBean [id=38, userId=Zorro, aRUserId=null, aRLoginName=null, uniqueId=arcathy-2, uuid=mdmdmdmdmdmdmdmd, firstName=fred, lastName=smith, fullName=fred smith, email=null, admin=false, ip=null, channelId=null, websocketEndpointURI=null, sessionID=null, issuedAt=null, expiration=null, lastActive=null, lastLoginOn=null, lastReported=null, lastPage=null, tK=null]
Java Class,
Note that getters and setters have been created by Eclipse.
import java.io.Serializable;
import java.util.logging.Logger;
@entity(kind="usersessions")
public class UserAccountSessionBean implements Serializable {
} // end class
The text was updated successfully, but these errors were encountered: