Re: why a GET method would store value to database?

2016-02-18 Thread Chuangyu
OK, I will try to do it.


2016-02-18 15:48 GMT+08:00 Dan Haywood :

> How about a pull request, James?  Process documented here [1] and details
> on the Asciidoc here [2].  Suggest add to the hints-n-tips section of the
> RO viewer's guide [3]; the actual file to change would be [4]
>
> Cheers
> Dan
>
>
> [1] http://isis.apache.org/guides/cgcon.html#_cgcon_contributing
> [2] http://isis.apache.org/guides/cgcon.html#_cgcon_asciidoc
> [3] http://isis.apache.org/guides/ugvro.html#_ugvro_hints-and-tips
> [4]
>
> https://github.com/apache/isis/blob/master/adocs/documentation/src/main/asciidoc/guides/_ugvro_hints-and-tips.adoc
>
>
> On 18 February 2016 at 02:31, Chuangyu  wrote:
>
> > Hi, Dan,
> >
> > Thank you for your work.
> >
> > You are right , I call GET method without prefix "s_" originally. Now it
> > works fine with "s_" + id.
> >
> > But this information doesn't documented, would you please put this into
> > document ?
> >
> > Thanks again,
> > James.
> >
> > 2016-02-17 16:41 GMT+08:00 Dan Haywood :
> >
> > > Hi James,
> > >
> > > OK, so I took a look at this yesterday; thanks for the example code.  I
> > > don't believe there's an issue, but I can see how one might make a
> > mistake
> > > to get the behaviour you are seeing.
> > >
> > > The IdEntity you introduced (which SimpleObject subclases) is defined
> to
> > > use application-defined identity, with an IdGenerator strategy of
> > UUIDHEX:
> > >
> > > @javax.jdo.annotations.PersistenceCapable(identityType=IdentityType.
> > > APPLICATION)
> > > @javax.jdo.annotations.Inheritance(strategy=javax.jdo.annotations.
> > > InheritanceStrategy.SUBCLASS_TABLE)
> > > public class IdEntity {
> > >
> > >@javax.jdo.annotations.Persistent(primaryKey="true",
> > > valueStrategy=javax.jdo.annotations.IdGeneratorStrategy.UUIDHEX)
> > >@javax.jdo.annotations.Column(jdbcType="CHAR",length=32)
> > >protected String id;
> > >
> > > }
> > >
> > > So, in the database, the SimpleObject.id column will have a value
> > something
> > > like "1234567890abcdef1234567890abcdef"
> > >
> > > If you invoke "SimpleObjects/listAll/invoke" in the swagger-ui, then
> > you'll
> > > see links for the SimpleObject objects, in the form:
> > >
> > >
> > >
> > >
> >
> http://localhost:8080/objects/simple.SimpleObject:s_1234567890abcdef1234567890abcdef
> > > .
> > >
> > > What's important to note here is that hex id has a "s_" prefix.  This
> is
> > > Isis adding some type encoding so that it knows how to correctly
> recreate
> > > the identifier for the object.
> > >
> > > If in the Swagger UI you use the "s_1234567890abcdef1234567890abcdef"
> as
> > > the Id when you GET the SimpleObject instance, it all works fine.
> > >
> > > If, however, you miss out the "s_" prefix (easy to do), then you'll get
> > the
> > > exception you reported.
> > >
> > > Hope that makes sense?
> > >
> > > Thx
> > > Dan
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > On 15 February 2016 at 02:28, Chuangyu  wrote:
> > >
> > > > Hi, Dan,
> > > >
> > > > Did you found the reason of issue ?
> > > >
> > > > Thanks,
> > > >
> > > > James
> > > >
> > > > ps: update class IdEntity
> > > >
> > > >
> > > >
> > >
> >
> @javax.jdo.annotations.PersistenceCapable(identityType=IdentityType.APPLICATION)
> > > >
> > > >
> > >
> >
> @javax.jdo.annotations.Inheritance(strategy=javax.jdo.annotations.InheritanceStrategy.SUBCLASS_TABLE)
> > > > @javax.jdo.annotations.Version(
> > > > strategy=VersionStrategy.VERSION_NUMBER,
> > > > column="version")
> > > > public class IdEntity {
> > > > protected String id;
> > > >
> > > >
> > >
> >
> @javax.jdo.annotations.Persistent(primaryKey="true",valueStrategy=javax.jdo.annotations.IdGeneratorStrategy.UUIDHEX)
> > > > @javax.jdo.annotations.Column(jdbcType="CHAR",length=32)
> > > > @Property(hidden=Where.ANYWHERE)
> > > > public String getId(){
> > > > return this.id;
> > > > }
> > > > public void setId(String id){
> > > > this.id=id;
> > > > }
> > > > private Long createdAt;
> > > > @Property(hidden=Where.EVERYWHERE)
> > > > @javax.jdo.annotations.Column(name="created_at",allowsNull="true")
> > > > public Long getCreatedAt(){
> > > > return this.createdAt;
> > > > }
> > > > public void setCreatedAt(Long time){
> > > > this.createdAt=time;
> > > > }
> > > > private Long updatedAt;
> > > > @Property(hidden=Where.EVERYWHERE)
> > > > @javax.jdo.annotations.Column(name="updated_at",allowsNull="true")
> > > > public Long getUpdatedAt(){
> > > > return this.updatedAt;
> > > > }
> > > > public void setUpdatedAt(Long time){
> > > > this.updatedAt=time;
> > > > }
> > > >
> > > > public void persisting(){
> > > > this.createdAt=clockService.nowAsMillis();
> > > > }
> > > > @javax.inject.Inject
> > > > protected ClockService clockService;
> > > > }
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > 2016-02-01 20:04 GMT+08:00 Dan Haywood 

Re: why a GET method would store value to database?

2016-02-17 Thread Dan Haywood
How about a pull request, James?  Process documented here [1] and details
on the Asciidoc here [2].  Suggest add to the hints-n-tips section of the
RO viewer's guide [3]; the actual file to change would be [4]

Cheers
Dan


[1] http://isis.apache.org/guides/cgcon.html#_cgcon_contributing
[2] http://isis.apache.org/guides/cgcon.html#_cgcon_asciidoc
[3] http://isis.apache.org/guides/ugvro.html#_ugvro_hints-and-tips
[4]
https://github.com/apache/isis/blob/master/adocs/documentation/src/main/asciidoc/guides/_ugvro_hints-and-tips.adoc


On 18 February 2016 at 02:31, Chuangyu  wrote:

> Hi, Dan,
>
> Thank you for your work.
>
> You are right , I call GET method without prefix "s_" originally. Now it
> works fine with "s_" + id.
>
> But this information doesn't documented, would you please put this into
> document ?
>
> Thanks again,
> James.
>
> 2016-02-17 16:41 GMT+08:00 Dan Haywood :
>
> > Hi James,
> >
> > OK, so I took a look at this yesterday; thanks for the example code.  I
> > don't believe there's an issue, but I can see how one might make a
> mistake
> > to get the behaviour you are seeing.
> >
> > The IdEntity you introduced (which SimpleObject subclases) is defined to
> > use application-defined identity, with an IdGenerator strategy of
> UUIDHEX:
> >
> > @javax.jdo.annotations.PersistenceCapable(identityType=IdentityType.
> > APPLICATION)
> > @javax.jdo.annotations.Inheritance(strategy=javax.jdo.annotations.
> > InheritanceStrategy.SUBCLASS_TABLE)
> > public class IdEntity {
> >
> >@javax.jdo.annotations.Persistent(primaryKey="true",
> > valueStrategy=javax.jdo.annotations.IdGeneratorStrategy.UUIDHEX)
> >@javax.jdo.annotations.Column(jdbcType="CHAR",length=32)
> >protected String id;
> >
> > }
> >
> > So, in the database, the SimpleObject.id column will have a value
> something
> > like "1234567890abcdef1234567890abcdef"
> >
> > If you invoke "SimpleObjects/listAll/invoke" in the swagger-ui, then
> you'll
> > see links for the SimpleObject objects, in the form:
> >
> >
> >
> >
> http://localhost:8080/objects/simple.SimpleObject:s_1234567890abcdef1234567890abcdef
> > .
> >
> > What's important to note here is that hex id has a "s_" prefix.  This is
> > Isis adding some type encoding so that it knows how to correctly recreate
> > the identifier for the object.
> >
> > If in the Swagger UI you use the "s_1234567890abcdef1234567890abcdef" as
> > the Id when you GET the SimpleObject instance, it all works fine.
> >
> > If, however, you miss out the "s_" prefix (easy to do), then you'll get
> the
> > exception you reported.
> >
> > Hope that makes sense?
> >
> > Thx
> > Dan
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On 15 February 2016 at 02:28, Chuangyu  wrote:
> >
> > > Hi, Dan,
> > >
> > > Did you found the reason of issue ?
> > >
> > > Thanks,
> > >
> > > James
> > >
> > > ps: update class IdEntity
> > >
> > >
> > >
> >
> @javax.jdo.annotations.PersistenceCapable(identityType=IdentityType.APPLICATION)
> > >
> > >
> >
> @javax.jdo.annotations.Inheritance(strategy=javax.jdo.annotations.InheritanceStrategy.SUBCLASS_TABLE)
> > > @javax.jdo.annotations.Version(
> > > strategy=VersionStrategy.VERSION_NUMBER,
> > > column="version")
> > > public class IdEntity {
> > > protected String id;
> > >
> > >
> >
> @javax.jdo.annotations.Persistent(primaryKey="true",valueStrategy=javax.jdo.annotations.IdGeneratorStrategy.UUIDHEX)
> > > @javax.jdo.annotations.Column(jdbcType="CHAR",length=32)
> > > @Property(hidden=Where.ANYWHERE)
> > > public String getId(){
> > > return this.id;
> > > }
> > > public void setId(String id){
> > > this.id=id;
> > > }
> > > private Long createdAt;
> > > @Property(hidden=Where.EVERYWHERE)
> > > @javax.jdo.annotations.Column(name="created_at",allowsNull="true")
> > > public Long getCreatedAt(){
> > > return this.createdAt;
> > > }
> > > public void setCreatedAt(Long time){
> > > this.createdAt=time;
> > > }
> > > private Long updatedAt;
> > > @Property(hidden=Where.EVERYWHERE)
> > > @javax.jdo.annotations.Column(name="updated_at",allowsNull="true")
> > > public Long getUpdatedAt(){
> > > return this.updatedAt;
> > > }
> > > public void setUpdatedAt(Long time){
> > > this.updatedAt=time;
> > > }
> > >
> > > public void persisting(){
> > > this.createdAt=clockService.nowAsMillis();
> > > }
> > > @javax.inject.Inject
> > > protected ClockService clockService;
> > > }
> > >
> > >
> > >
> > >
> > >
> > > 2016-02-01 20:04 GMT+08:00 Dan Haywood :
> > >
> > > > Ok, James, thanks for taking the time to look into.
> > > > Will take a look later this week,try to get to the bottom of it .
> > > > Thx, Dan
> > > > On 1 Feb 2016 12:45, "Chuangyu"  wrote:
> > > >
> > > > > Hi, Dan,
> > > > >
> > > > > I replay the error with simpleapp.
> > > > >
> > > > > There is one new class called IdEntity, and modify SimpleObject to
> > > > extends
> > > > > 

Re: why a GET method would store value to database?

2016-02-17 Thread Chuangyu
Hi, Dan,

Thank you for your work.

You are right , I call GET method without prefix "s_" originally. Now it
works fine with "s_" + id.

But this information doesn't documented, would you please put this into
document ?

Thanks again,
James.

2016-02-17 16:41 GMT+08:00 Dan Haywood :

> Hi James,
>
> OK, so I took a look at this yesterday; thanks for the example code.  I
> don't believe there's an issue, but I can see how one might make a mistake
> to get the behaviour you are seeing.
>
> The IdEntity you introduced (which SimpleObject subclases) is defined to
> use application-defined identity, with an IdGenerator strategy of UUIDHEX:
>
> @javax.jdo.annotations.PersistenceCapable(identityType=IdentityType.
> APPLICATION)
> @javax.jdo.annotations.Inheritance(strategy=javax.jdo.annotations.
> InheritanceStrategy.SUBCLASS_TABLE)
> public class IdEntity {
>
>@javax.jdo.annotations.Persistent(primaryKey="true",
> valueStrategy=javax.jdo.annotations.IdGeneratorStrategy.UUIDHEX)
>@javax.jdo.annotations.Column(jdbcType="CHAR",length=32)
>protected String id;
>
> }
>
> So, in the database, the SimpleObject.id column will have a value something
> like "1234567890abcdef1234567890abcdef"
>
> If you invoke "SimpleObjects/listAll/invoke" in the swagger-ui, then you'll
> see links for the SimpleObject objects, in the form:
>
>
>
> http://localhost:8080/objects/simple.SimpleObject:s_1234567890abcdef1234567890abcdef
> .
>
> What's important to note here is that hex id has a "s_" prefix.  This is
> Isis adding some type encoding so that it knows how to correctly recreate
> the identifier for the object.
>
> If in the Swagger UI you use the "s_1234567890abcdef1234567890abcdef" as
> the Id when you GET the SimpleObject instance, it all works fine.
>
> If, however, you miss out the "s_" prefix (easy to do), then you'll get the
> exception you reported.
>
> Hope that makes sense?
>
> Thx
> Dan
>
>
>
>
>
>
>
>
>
> On 15 February 2016 at 02:28, Chuangyu  wrote:
>
> > Hi, Dan,
> >
> > Did you found the reason of issue ?
> >
> > Thanks,
> >
> > James
> >
> > ps: update class IdEntity
> >
> >
> >
> @javax.jdo.annotations.PersistenceCapable(identityType=IdentityType.APPLICATION)
> >
> >
> @javax.jdo.annotations.Inheritance(strategy=javax.jdo.annotations.InheritanceStrategy.SUBCLASS_TABLE)
> > @javax.jdo.annotations.Version(
> > strategy=VersionStrategy.VERSION_NUMBER,
> > column="version")
> > public class IdEntity {
> > protected String id;
> >
> >
> @javax.jdo.annotations.Persistent(primaryKey="true",valueStrategy=javax.jdo.annotations.IdGeneratorStrategy.UUIDHEX)
> > @javax.jdo.annotations.Column(jdbcType="CHAR",length=32)
> > @Property(hidden=Where.ANYWHERE)
> > public String getId(){
> > return this.id;
> > }
> > public void setId(String id){
> > this.id=id;
> > }
> > private Long createdAt;
> > @Property(hidden=Where.EVERYWHERE)
> > @javax.jdo.annotations.Column(name="created_at",allowsNull="true")
> > public Long getCreatedAt(){
> > return this.createdAt;
> > }
> > public void setCreatedAt(Long time){
> > this.createdAt=time;
> > }
> > private Long updatedAt;
> > @Property(hidden=Where.EVERYWHERE)
> > @javax.jdo.annotations.Column(name="updated_at",allowsNull="true")
> > public Long getUpdatedAt(){
> > return this.updatedAt;
> > }
> > public void setUpdatedAt(Long time){
> > this.updatedAt=time;
> > }
> >
> > public void persisting(){
> > this.createdAt=clockService.nowAsMillis();
> > }
> > @javax.inject.Inject
> > protected ClockService clockService;
> > }
> >
> >
> >
> >
> >
> > 2016-02-01 20:04 GMT+08:00 Dan Haywood :
> >
> > > Ok, James, thanks for taking the time to look into.
> > > Will take a look later this week,try to get to the bottom of it .
> > > Thx, Dan
> > > On 1 Feb 2016 12:45, "Chuangyu"  wrote:
> > >
> > > > Hi, Dan,
> > > >
> > > > I replay the error with simpleapp.
> > > >
> > > > There is one new class called IdEntity, and modify SimpleObject to
> > > extends
> > > > IdEntity.
> > > >
> > > > public class IdEntity {
> > > > protected String id;
> > > >
> > > >
> > >
> >
> @javax.jdo.annotations.Persistent(primaryKey="true",valueStrategy=javax.jdo.annotations.IdGeneratorStrategy.UUIDHEX)
> > > > @javax.jdo.annotations.Column(jdbcType="CHAR",length=32)
> > > > @Property(hidden=Where.ANYWHERE)
> > > > public String getId(){
> > > > return this.id;
> > > > }
> > > > public void setId(String id){
> > > > this.id=id;
> > > > }
> > > > private Long createdAt;
> > > > @Property(hidden=Where.EVERYWHERE)
> > > > @javax.jdo.annotations.Column(name="created_at",allowsNull="true")
> > > > public Long getCreatedAt(){
> > > > return this.createdAt;
> > > > }
> > > > public void setCreatedAt(Long time){
> > > > this.createdAt=time;
> > > > }
> > > > private Long updatedAt;
> > > > @Property(hidden=Where.EVERYWHERE)
> > > > 

Re: why a GET method would store value to database?

2016-02-17 Thread Dan Haywood
Hi James,

OK, so I took a look at this yesterday; thanks for the example code.  I
don't believe there's an issue, but I can see how one might make a mistake
to get the behaviour you are seeing.

The IdEntity you introduced (which SimpleObject subclases) is defined to
use application-defined identity, with an IdGenerator strategy of UUIDHEX:

@javax.jdo.annotations.PersistenceCapable(identityType=IdentityType.
APPLICATION)
@javax.jdo.annotations.Inheritance(strategy=javax.jdo.annotations.
InheritanceStrategy.SUBCLASS_TABLE)
public class IdEntity {

   @javax.jdo.annotations.Persistent(primaryKey="true",
valueStrategy=javax.jdo.annotations.IdGeneratorStrategy.UUIDHEX)
   @javax.jdo.annotations.Column(jdbcType="CHAR",length=32)
   protected String id;

}

So, in the database, the SimpleObject.id column will have a value something
like "1234567890abcdef1234567890abcdef"

If you invoke "SimpleObjects/listAll/invoke" in the swagger-ui, then you'll
see links for the SimpleObject objects, in the form:


http://localhost:8080/objects/simple.SimpleObject:s_1234567890abcdef1234567890abcdef
.

What's important to note here is that hex id has a "s_" prefix.  This is
Isis adding some type encoding so that it knows how to correctly recreate
the identifier for the object.

If in the Swagger UI you use the "s_1234567890abcdef1234567890abcdef" as
the Id when you GET the SimpleObject instance, it all works fine.

If, however, you miss out the "s_" prefix (easy to do), then you'll get the
exception you reported.

Hope that makes sense?

Thx
Dan









On 15 February 2016 at 02:28, Chuangyu  wrote:

> Hi, Dan,
>
> Did you found the reason of issue ?
>
> Thanks,
>
> James
>
> ps: update class IdEntity
>
>
> @javax.jdo.annotations.PersistenceCapable(identityType=IdentityType.APPLICATION)
>
> @javax.jdo.annotations.Inheritance(strategy=javax.jdo.annotations.InheritanceStrategy.SUBCLASS_TABLE)
> @javax.jdo.annotations.Version(
> strategy=VersionStrategy.VERSION_NUMBER,
> column="version")
> public class IdEntity {
> protected String id;
>
> @javax.jdo.annotations.Persistent(primaryKey="true",valueStrategy=javax.jdo.annotations.IdGeneratorStrategy.UUIDHEX)
> @javax.jdo.annotations.Column(jdbcType="CHAR",length=32)
> @Property(hidden=Where.ANYWHERE)
> public String getId(){
> return this.id;
> }
> public void setId(String id){
> this.id=id;
> }
> private Long createdAt;
> @Property(hidden=Where.EVERYWHERE)
> @javax.jdo.annotations.Column(name="created_at",allowsNull="true")
> public Long getCreatedAt(){
> return this.createdAt;
> }
> public void setCreatedAt(Long time){
> this.createdAt=time;
> }
> private Long updatedAt;
> @Property(hidden=Where.EVERYWHERE)
> @javax.jdo.annotations.Column(name="updated_at",allowsNull="true")
> public Long getUpdatedAt(){
> return this.updatedAt;
> }
> public void setUpdatedAt(Long time){
> this.updatedAt=time;
> }
>
> public void persisting(){
> this.createdAt=clockService.nowAsMillis();
> }
> @javax.inject.Inject
> protected ClockService clockService;
> }
>
>
>
>
>
> 2016-02-01 20:04 GMT+08:00 Dan Haywood :
>
> > Ok, James, thanks for taking the time to look into.
> > Will take a look later this week,try to get to the bottom of it .
> > Thx, Dan
> > On 1 Feb 2016 12:45, "Chuangyu"  wrote:
> >
> > > Hi, Dan,
> > >
> > > I replay the error with simpleapp.
> > >
> > > There is one new class called IdEntity, and modify SimpleObject to
> > extends
> > > IdEntity.
> > >
> > > public class IdEntity {
> > > protected String id;
> > >
> > >
> >
> @javax.jdo.annotations.Persistent(primaryKey="true",valueStrategy=javax.jdo.annotations.IdGeneratorStrategy.UUIDHEX)
> > > @javax.jdo.annotations.Column(jdbcType="CHAR",length=32)
> > > @Property(hidden=Where.ANYWHERE)
> > > public String getId(){
> > > return this.id;
> > > }
> > > public void setId(String id){
> > > this.id=id;
> > > }
> > > private Long createdAt;
> > > @Property(hidden=Where.EVERYWHERE)
> > > @javax.jdo.annotations.Column(name="created_at",allowsNull="true")
> > > public Long getCreatedAt(){
> > > return this.createdAt;
> > > }
> > > public void setCreatedAt(Long time){
> > > this.createdAt=time;
> > > }
> > > private Long updatedAt;
> > > @Property(hidden=Where.EVERYWHERE)
> > > @javax.jdo.annotations.Column(name="updated_at",allowsNull="true")
> > > public Long getUpdatedAt(){
> > > return this.updatedAt;
> > > }
> > > public void setUpdatedAt(Long time){
> > > this.updatedAt=time;
> > > }
> > >
> > > public void persisting(){
> > > this.createdAt=clockService.nowAsMillis();
> > > }
> > > @javax.inject.Inject
> > > protected ClockService clockService;
> > > }
> > >
> > >
> > > @javax.jdo.annotations.PersistenceCapable(
> > > table = "SimpleObject",
> > > identityType=IdentityType.APPLICATION
> > > )
> > > //@javax.jdo.annotations.DatastoreIdentity(
> > > //strategy=javax.jdo.annotations.IdGeneratorStrategy.IDENTITY,
> > 

Re: why a GET method would store value to database?

2016-02-14 Thread Chuangyu
Hi, Dan,

Did you found the reason of issue ?

Thanks,

James

ps: update class IdEntity

@javax.jdo.annotations.PersistenceCapable(identityType=IdentityType.APPLICATION)
@javax.jdo.annotations.Inheritance(strategy=javax.jdo.annotations.InheritanceStrategy.SUBCLASS_TABLE)
@javax.jdo.annotations.Version(
strategy=VersionStrategy.VERSION_NUMBER,
column="version")
public class IdEntity {
protected String id;
@javax.jdo.annotations.Persistent(primaryKey="true",valueStrategy=javax.jdo.annotations.IdGeneratorStrategy.UUIDHEX)
@javax.jdo.annotations.Column(jdbcType="CHAR",length=32)
@Property(hidden=Where.ANYWHERE)
public String getId(){
return this.id;
}
public void setId(String id){
this.id=id;
}
private Long createdAt;
@Property(hidden=Where.EVERYWHERE)
@javax.jdo.annotations.Column(name="created_at",allowsNull="true")
public Long getCreatedAt(){
return this.createdAt;
}
public void setCreatedAt(Long time){
this.createdAt=time;
}
private Long updatedAt;
@Property(hidden=Where.EVERYWHERE)
@javax.jdo.annotations.Column(name="updated_at",allowsNull="true")
public Long getUpdatedAt(){
return this.updatedAt;
}
public void setUpdatedAt(Long time){
this.updatedAt=time;
}

public void persisting(){
this.createdAt=clockService.nowAsMillis();
}
@javax.inject.Inject
protected ClockService clockService;
}





2016-02-01 20:04 GMT+08:00 Dan Haywood :

> Ok, James, thanks for taking the time to look into.
> Will take a look later this week,try to get to the bottom of it .
> Thx, Dan
> On 1 Feb 2016 12:45, "Chuangyu"  wrote:
>
> > Hi, Dan,
> >
> > I replay the error with simpleapp.
> >
> > There is one new class called IdEntity, and modify SimpleObject to
> extends
> > IdEntity.
> >
> > public class IdEntity {
> > protected String id;
> >
> >
> @javax.jdo.annotations.Persistent(primaryKey="true",valueStrategy=javax.jdo.annotations.IdGeneratorStrategy.UUIDHEX)
> > @javax.jdo.annotations.Column(jdbcType="CHAR",length=32)
> > @Property(hidden=Where.ANYWHERE)
> > public String getId(){
> > return this.id;
> > }
> > public void setId(String id){
> > this.id=id;
> > }
> > private Long createdAt;
> > @Property(hidden=Where.EVERYWHERE)
> > @javax.jdo.annotations.Column(name="created_at",allowsNull="true")
> > public Long getCreatedAt(){
> > return this.createdAt;
> > }
> > public void setCreatedAt(Long time){
> > this.createdAt=time;
> > }
> > private Long updatedAt;
> > @Property(hidden=Where.EVERYWHERE)
> > @javax.jdo.annotations.Column(name="updated_at",allowsNull="true")
> > public Long getUpdatedAt(){
> > return this.updatedAt;
> > }
> > public void setUpdatedAt(Long time){
> > this.updatedAt=time;
> > }
> >
> > public void persisting(){
> > this.createdAt=clockService.nowAsMillis();
> > }
> > @javax.inject.Inject
> > protected ClockService clockService;
> > }
> >
> >
> > @javax.jdo.annotations.PersistenceCapable(
> > table = "SimpleObject",
> > identityType=IdentityType.APPLICATION
> > )
> > //@javax.jdo.annotations.DatastoreIdentity(
> > //strategy=javax.jdo.annotations.IdGeneratorStrategy.IDENTITY,
> > // column="id")
> > //@javax.jdo.annotations.Version(
> > //strategy=VersionStrategy.VERSION_NUMBER,
> > //strategy= VersionStrategy.DATE_TIME,
> > //column="version")
> > @javax.jdo.annotations.Queries({
> > @javax.jdo.annotations.Query(
> > name = "find", language = "JDOQL",
> > value = "SELECT "
> > + "FROM domainapp.dom.simple.SimpleObject "),
> > @javax.jdo.annotations.Query(
> > name = "findByName", language = "JDOQL",
> > value = "SELECT "
> > + "FROM domainapp.dom.simple.SimpleObject "
> > + "WHERE name.indexOf(:name) >= 0 ")
> > })
> > @javax.jdo.annotations.Unique(name="SimpleObject_name_UNQ", members =
> > {"name"})
> > @DomainObject
> > @DomainObjectLayout(
> > bookmarking = BookmarkPolicy.AS_ROOT
> > )
> > public class SimpleObject extends IdEntity implements
> > Comparable {
> >
> > public static final int NAME_LENGTH = 40;
> >
> >
> > public TranslatableString title() {
> > return TranslatableString.tr("Object: {name}", "name",
> getName());
> > }
> >
> > public static class NameDomainEvent extends
> > PropertyDomainEvent {}
> > @javax.jdo.annotations.Column(
> > allowsNull="false",
> > length = NAME_LENGTH
> > )
> > @Property(
> > editing = Editing.DISABLED
> > )
> > @PropertyLayout(
> > namedEscaped = false
> > )
> > private String name;
> > public String getName() {
> > return name;
> > }
> > public void setName(final String name) {
> > this.name = name;
> > }
> >
> >
> >
> > public static class UpdateNameDomainEvent extends
> > ActionDomainEvent {}
> > @Action(
> >   

Re: why a GET method would store value to database?

2016-02-01 Thread Chuangyu
Hi, Dan,

I replay the error with simpleapp.

There is one new class called IdEntity, and modify SimpleObject to extends
IdEntity.

public class IdEntity {
protected String id;
@javax.jdo.annotations.Persistent(primaryKey="true",valueStrategy=javax.jdo.annotations.IdGeneratorStrategy.UUIDHEX)
@javax.jdo.annotations.Column(jdbcType="CHAR",length=32)
@Property(hidden=Where.ANYWHERE)
public String getId(){
return this.id;
}
public void setId(String id){
this.id=id;
}
private Long createdAt;
@Property(hidden=Where.EVERYWHERE)
@javax.jdo.annotations.Column(name="created_at",allowsNull="true")
public Long getCreatedAt(){
return this.createdAt;
}
public void setCreatedAt(Long time){
this.createdAt=time;
}
private Long updatedAt;
@Property(hidden=Where.EVERYWHERE)
@javax.jdo.annotations.Column(name="updated_at",allowsNull="true")
public Long getUpdatedAt(){
return this.updatedAt;
}
public void setUpdatedAt(Long time){
this.updatedAt=time;
}

public void persisting(){
this.createdAt=clockService.nowAsMillis();
}
@javax.inject.Inject
protected ClockService clockService;
}


@javax.jdo.annotations.PersistenceCapable(
table = "SimpleObject",
identityType=IdentityType.APPLICATION
)
//@javax.jdo.annotations.DatastoreIdentity(
//strategy=javax.jdo.annotations.IdGeneratorStrategy.IDENTITY,
// column="id")
//@javax.jdo.annotations.Version(
//strategy=VersionStrategy.VERSION_NUMBER,
//strategy= VersionStrategy.DATE_TIME,
//column="version")
@javax.jdo.annotations.Queries({
@javax.jdo.annotations.Query(
name = "find", language = "JDOQL",
value = "SELECT "
+ "FROM domainapp.dom.simple.SimpleObject "),
@javax.jdo.annotations.Query(
name = "findByName", language = "JDOQL",
value = "SELECT "
+ "FROM domainapp.dom.simple.SimpleObject "
+ "WHERE name.indexOf(:name) >= 0 ")
})
@javax.jdo.annotations.Unique(name="SimpleObject_name_UNQ", members =
{"name"})
@DomainObject
@DomainObjectLayout(
bookmarking = BookmarkPolicy.AS_ROOT
)
public class SimpleObject extends IdEntity implements
Comparable {

public static final int NAME_LENGTH = 40;


public TranslatableString title() {
return TranslatableString.tr("Object: {name}", "name", getName());
}

public static class NameDomainEvent extends
PropertyDomainEvent {}
@javax.jdo.annotations.Column(
allowsNull="false",
length = NAME_LENGTH
)
@Property(
editing = Editing.DISABLED
)
@PropertyLayout(
namedEscaped = false
)
private String name;
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}



public static class UpdateNameDomainEvent extends
ActionDomainEvent {}
@Action(
domainEvent = UpdateNameDomainEvent.class,
semantics = SemanticsOf.IDEMPOTENT
)
public SimpleObject updateName(
@Parameter(maxLength = NAME_LENGTH)
@ParameterLayout(named = "New name")
final String name) {
setName(name);
return this;
}
public String default0UpdateName() {
return getName();
}
public TranslatableString validateUpdateName(final String name) {
return name.contains("!")? TranslatableString.tr("Exclamation mark
is not allowed"): null;
}



public static class DeleteDomainEvent extends
ActionDomainEvent {}
@Action(
domainEvent = DeleteDomainEvent.class,
semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE
)
public void delete() {
container.removeIfNotAlready(this);
}


/**
 * version (derived property)
 */
public Integer getVersionSequence() {
return (Integer) JDOHelper.getVersion(this);
}


@Override
public int compareTo(final SimpleObject other) {
return ObjectContracts.compare(this, other, "name");
}


@javax.inject.Inject
@SuppressWarnings("unused")
private DomainObjectContainer container;

}

The error message is same as "Attempt to store value...".

Regards,
James

2016-01-25 19:18 GMT+08:00 Dan Haywood :

> As Martin says, the DN error is perhaps a bit misleading ... I believe the
> "store" action here is DN repopulating the pojo with data from the
> database, rather than the other way around.
>
> In Isis the JdoObjectIdSerializer class [1] is responsible for converting
> between the Isis RootOid and the DN ObjectId; the format "
> 4028dd814d2213d8014d2213d861[OID]tm.dom.modules.assets.Device" is a
> valid value for the OID,
>
> Could you provide a test example based on simpleapp that demonstrates the
> problem?  It might be to do with the particular annotations/mappings that
> you have on your Device class.
>
> Thanks
> Dan
>

Re: why a GET method would store value to database?

2016-02-01 Thread Dan Haywood
Ok, James, thanks for taking the time to look into.
Will take a look later this week,try to get to the bottom of it .
Thx, Dan
On 1 Feb 2016 12:45, "Chuangyu"  wrote:

> Hi, Dan,
>
> I replay the error with simpleapp.
>
> There is one new class called IdEntity, and modify SimpleObject to extends
> IdEntity.
>
> public class IdEntity {
> protected String id;
>
> @javax.jdo.annotations.Persistent(primaryKey="true",valueStrategy=javax.jdo.annotations.IdGeneratorStrategy.UUIDHEX)
> @javax.jdo.annotations.Column(jdbcType="CHAR",length=32)
> @Property(hidden=Where.ANYWHERE)
> public String getId(){
> return this.id;
> }
> public void setId(String id){
> this.id=id;
> }
> private Long createdAt;
> @Property(hidden=Where.EVERYWHERE)
> @javax.jdo.annotations.Column(name="created_at",allowsNull="true")
> public Long getCreatedAt(){
> return this.createdAt;
> }
> public void setCreatedAt(Long time){
> this.createdAt=time;
> }
> private Long updatedAt;
> @Property(hidden=Where.EVERYWHERE)
> @javax.jdo.annotations.Column(name="updated_at",allowsNull="true")
> public Long getUpdatedAt(){
> return this.updatedAt;
> }
> public void setUpdatedAt(Long time){
> this.updatedAt=time;
> }
>
> public void persisting(){
> this.createdAt=clockService.nowAsMillis();
> }
> @javax.inject.Inject
> protected ClockService clockService;
> }
>
>
> @javax.jdo.annotations.PersistenceCapable(
> table = "SimpleObject",
> identityType=IdentityType.APPLICATION
> )
> //@javax.jdo.annotations.DatastoreIdentity(
> //strategy=javax.jdo.annotations.IdGeneratorStrategy.IDENTITY,
> // column="id")
> //@javax.jdo.annotations.Version(
> //strategy=VersionStrategy.VERSION_NUMBER,
> //strategy= VersionStrategy.DATE_TIME,
> //column="version")
> @javax.jdo.annotations.Queries({
> @javax.jdo.annotations.Query(
> name = "find", language = "JDOQL",
> value = "SELECT "
> + "FROM domainapp.dom.simple.SimpleObject "),
> @javax.jdo.annotations.Query(
> name = "findByName", language = "JDOQL",
> value = "SELECT "
> + "FROM domainapp.dom.simple.SimpleObject "
> + "WHERE name.indexOf(:name) >= 0 ")
> })
> @javax.jdo.annotations.Unique(name="SimpleObject_name_UNQ", members =
> {"name"})
> @DomainObject
> @DomainObjectLayout(
> bookmarking = BookmarkPolicy.AS_ROOT
> )
> public class SimpleObject extends IdEntity implements
> Comparable {
>
> public static final int NAME_LENGTH = 40;
>
>
> public TranslatableString title() {
> return TranslatableString.tr("Object: {name}", "name", getName());
> }
>
> public static class NameDomainEvent extends
> PropertyDomainEvent {}
> @javax.jdo.annotations.Column(
> allowsNull="false",
> length = NAME_LENGTH
> )
> @Property(
> editing = Editing.DISABLED
> )
> @PropertyLayout(
> namedEscaped = false
> )
> private String name;
> public String getName() {
> return name;
> }
> public void setName(final String name) {
> this.name = name;
> }
>
>
>
> public static class UpdateNameDomainEvent extends
> ActionDomainEvent {}
> @Action(
> domainEvent = UpdateNameDomainEvent.class,
> semantics = SemanticsOf.IDEMPOTENT
> )
> public SimpleObject updateName(
> @Parameter(maxLength = NAME_LENGTH)
> @ParameterLayout(named = "New name")
> final String name) {
> setName(name);
> return this;
> }
> public String default0UpdateName() {
> return getName();
> }
> public TranslatableString validateUpdateName(final String name) {
> return name.contains("!")? TranslatableString.tr("Exclamation mark
> is not allowed"): null;
> }
>
>
>
> public static class DeleteDomainEvent extends
> ActionDomainEvent {}
> @Action(
> domainEvent = DeleteDomainEvent.class,
> semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE
> )
> public void delete() {
> container.removeIfNotAlready(this);
> }
>
>
> /**
>  * version (derived property)
>  */
> public Integer getVersionSequence() {
> return (Integer) JDOHelper.getVersion(this);
> }
>
>
> @Override
> public int compareTo(final SimpleObject other) {
> return ObjectContracts.compare(this, other, "name");
> }
>
>
> @javax.inject.Inject
> @SuppressWarnings("unused")
> private DomainObjectContainer container;
>
> }
>
> The error message is same as "Attempt to store value...".
>
> Regards,
> James
>
> 2016-01-25 19:18 GMT+08:00 Dan Haywood :
>
> > As Martin says, the DN error is perhaps a bit misleading ... I believe
> the
> > "store" action here is DN repopulating the pojo with 

Re: why a GET method would store value to database?

2016-01-25 Thread Martin Grigorov
Hi,

I believe there are two issues here:

1) Isis doesn't extract the primary key (4028dd814d2213d8014d2213d861)
from "4028dd814d2213d8014d2213d861[OID]tm.dom.modules.assets.Device"
before passing it to DataNucleus
2) DataNucleus uses misleading exception message. The method call is
#getObjectById().
I guess it uses something like JDOQL with template object, e.g.
Device device = new Device();
device.setId("4028dd814d2213d8014d2213d861[OID]tm.dom.modules.assets.Device");
 // 1
SELECT * FROM Device dev WHERE dev.getId() = device.getId();

and it fails at [1].

I have no experience with DataNucleus so this is just a guess. And the
given JDOQL above is most probably very wrong, but you get the idea.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Mon, Jan 25, 2016 at 2:39 AM, Chuangyu  wrote:

> Hi,
>
> I met an error when try a GET method with Swagger UI.
>
> The url is below:
>
>
> http://localhost:8080/restful/objects/tm.dom.modules.assets.Device/4028dd814d2213d8014d2213d861
>
>
> "4028dd814d2213d8014d2213d861" is a uuid string which length is 32.
>
>  curl command as below:
>
> curl -X GET --header "Accept:
> application/json;profile=urn:org.apache.isis/v1" --header
> "Authorization: Basic c3lzdGVtLWFkbWluOmdvb2dmcmllbmc="
> "
> http://localhost:8080/restful/objects/tm.dom.modules.assets.Device/4028dd814d2213d8014d2213d861
> "
>
>
> error message sa below:
>
> { "className": "javax.jdo.JDOFatalUserException", "message": "Attempt to
> store value
> \"4028dd814d2213d8014d2213d861[OID]tm.dom.modules.assets.Device\" in
> column \"id\" that has maximum length of 32. Please correct your data!", "
> stackTrace": [
>
> "org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:616)",
>
> "org.datanucleus.api.jdo.JDOPersistenceManager.getObjectById(JDOPersistenceManager.java:1728)",
>
> "org.datanucleus.api.jdo.JDOPersistenceManager.getObjectById(JDOPersistenceManager.java:1741)",
>
> "org.apache.isis.core.runtime.system.persistence.PersistenceSession.loadPojo(PersistenceSession.java:885)",
>
> "org.apache.isis.core.runtime.system.persistence.PersistenceSession$2.execute(PersistenceSession.java:866)",
>
> "org.apache.isis.core.runtime.system.persistence.PersistenceSession$2.execute(PersistenceSession.java:859)",
>
> "org.apache.isis.core.runtime.system.transaction.IsisTransactionManager.executeWithinTransaction(IsisTransactionManager.java:216)",
>
> "org.apache.isis.core.runtime.system.persistence.PersistenceSession.loadObjectInTransaction(PersistenceSession.java:858)",
>
> "org.apache.isis.core.runtime.system.persistence.PersistenceSession.adapterForAny(PersistenceSession.java:1507)",
>
> "org.apache.isis.viewer.restfulobjects.server.util.OidUtils.getObjectAdapter(OidUtils.java:60)",
>
> "org.apache.isis.viewer.restfulobjects.server.util.OidUtils.getObjectAdapterElseNull(OidUtils.java:40)",
>
> "org.apache.isis.viewer.restfulobjects.server.resources.ResourceAbstract.getObjectAdapterElseNull(ResourceAbstract.java:151)",
>
> "org.apache.isis.viewer.restfulobjects.server.resources.ResourceAbstract.getObjectAdapterElseThrowNotFound(ResourceAbstract.java:141)",
>
> "org.apache.isis.viewer.restfulobjects.server.resources.DomainObjectResourceServerside.object(DomainObjectResourceServerside.java:123)",
> "sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)",
>
> "sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)",
>
> "sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)",
> "java.lang.reflect.Method.invoke(Method.java:497)",
>
> "org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:137)",
>
> "org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:296)",
>
> "org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:250)",
>
> "org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:237)",
>
> "org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356)",
>
> "org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179)",
>
> "org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220)",
>
> "org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)",
>
> "org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)",
> "javax.servlet.http.HttpServlet.service(HttpServlet.java:790)",
> "org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)",
>
> "org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)",
>
> "org.apache.isis.viewer.restfulobjects.server.webapp.IsisTransactionFilterForRestfulObjects.doFilter(IsisTransactionFilterForRestfulObjects.java:46)",
>
> 

why a GET method would store value to database?

2016-01-24 Thread Chuangyu
Hi,

I met an error when try a GET method with Swagger UI.

The url is below:

http://localhost:8080/restful/objects/tm.dom.modules.assets.Device/4028dd814d2213d8014d2213d861


"4028dd814d2213d8014d2213d861" is a uuid string which length is 32.

 curl command as below:

curl -X GET --header "Accept:
application/json;profile=urn:org.apache.isis/v1" --header
"Authorization: Basic c3lzdGVtLWFkbWluOmdvb2dmcmllbmc="
"http://localhost:8080/restful/objects/tm.dom.modules.assets.Device/4028dd814d2213d8014d2213d861;


error message sa below:

{ "className": "javax.jdo.JDOFatalUserException", "message": "Attempt to
store value
\"4028dd814d2213d8014d2213d861[OID]tm.dom.modules.assets.Device\" in
column \"id\" that has maximum length of 32. Please correct your data!", "
stackTrace": [
"org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:616)",
"org.datanucleus.api.jdo.JDOPersistenceManager.getObjectById(JDOPersistenceManager.java:1728)",
"org.datanucleus.api.jdo.JDOPersistenceManager.getObjectById(JDOPersistenceManager.java:1741)",
"org.apache.isis.core.runtime.system.persistence.PersistenceSession.loadPojo(PersistenceSession.java:885)",
"org.apache.isis.core.runtime.system.persistence.PersistenceSession$2.execute(PersistenceSession.java:866)",
"org.apache.isis.core.runtime.system.persistence.PersistenceSession$2.execute(PersistenceSession.java:859)",
"org.apache.isis.core.runtime.system.transaction.IsisTransactionManager.executeWithinTransaction(IsisTransactionManager.java:216)",
"org.apache.isis.core.runtime.system.persistence.PersistenceSession.loadObjectInTransaction(PersistenceSession.java:858)",
"org.apache.isis.core.runtime.system.persistence.PersistenceSession.adapterForAny(PersistenceSession.java:1507)",
"org.apache.isis.viewer.restfulobjects.server.util.OidUtils.getObjectAdapter(OidUtils.java:60)",
"org.apache.isis.viewer.restfulobjects.server.util.OidUtils.getObjectAdapterElseNull(OidUtils.java:40)",
"org.apache.isis.viewer.restfulobjects.server.resources.ResourceAbstract.getObjectAdapterElseNull(ResourceAbstract.java:151)",
"org.apache.isis.viewer.restfulobjects.server.resources.ResourceAbstract.getObjectAdapterElseThrowNotFound(ResourceAbstract.java:141)",
"org.apache.isis.viewer.restfulobjects.server.resources.DomainObjectResourceServerside.object(DomainObjectResourceServerside.java:123)",
"sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)",
"sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)",
"sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)",
"java.lang.reflect.Method.invoke(Method.java:497)",
"org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:137)",
"org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:296)",
"org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:250)",
"org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:237)",
"org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356)",
"org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179)",
"org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220)",
"org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)",
"org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)",
"javax.servlet.http.HttpServlet.service(HttpServlet.java:790)",
"org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)",
"org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)",
"org.apache.isis.viewer.restfulobjects.server.webapp.IsisTransactionFilterForRestfulObjects.doFilter(IsisTransactionFilterForRestfulObjects.java:46)",
"org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)",
"org.apache.isis.core.webapp.IsisSessionFilter.doFilter(IsisSessionFilter.java:338)",
"org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)",
"org.apache.isis.core.webapp.diagnostics.IsisLogOnExceptionFilter.doFilter(IsisLogOnExceptionFilter.java:52)",
"org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)",
"org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)",
"org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)",
"org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)",
"org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)",
"org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)",
"org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)",