You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by nhhockeyplayer nashua <nh...@hotmail.com> on 2015/01/31 19:31:54 UTC
@Embedded properties null not supported in T5.4 ???
Folks,
I am wondering if null properties are suppose to be dealt with morwe gracefully within T-5.4 as everytime I create an object it works fine and is displayed within my gallery widget but if I omit property fields declared inside @Embeddable classes, they get stored in hibernate as nulls and any subsequent Edits crash the app due to these omissions. Is tapestry suppose to handle this properly to avoid crash ?
Alleged as follows...
I have a curious EditBlock DisplayBlock issue with regard to entity in hibernate database.
Here is the model layout
I have Person.Java where Person is a base class Player class
But Person.Java has a data member
private Demographics demographics = new Demographics();
and here is how Demographics is declared
Demographics.Java...
@Embeddable
public class Demographics
ok so
Player extends from Person
Person has demographics
Player declares the following:
@Column(columnDefinition = "longtext", length = 6291456)
@PropertyDescriptor(readOnly = false)
public String getBio() {
return bio;
}
My issue is weird... Currently I can create Players at this demo site
http://psinh.ddns.net:9011/psi/home
If I create a player it gets saved fine
On subsequent EDIT operations (you can edit as player by clicking on any image in Gallery)...
Only Players who's demographics were all filled in with legitimate string data get displayed and edited.
The problem being... the app crashes on Players who's Demographics were omitted on creation and all properties within the @Embedded instance are null.
Its reproducible everytime at http://psinh.ddns.net:9011/psi/home
Here is the crash trace
An exception has occurred processing this request.
Render queue error in SetupRender[tynamo/PropertyEditBlocks:editor]: Exception instantiating instance of org.tynamo.psi.psi.model.Demographics (for component 'tynamo/PropertyEditBlocks:editor'): org.apache.tapestry5.ioc.internal.OperationException: No service implements the interface java.lang.String.
with reload: Force a reload of component classes. This is often necessary after fixing a class that previously failed to compile due to errors.
org.apache.tapestry5.internal.services.RenderQueueException
Render queue error in SetupRender[tynamo/PropertyEditBlocks:editor]: Exception instantiating instance of org.tynamo.psi.psi.model.Demographics (for component 'tynamo/PropertyEditBlocks:editor'): org.apache.tapestry5.ioc.internal.OperationException: No service implements the interface java.lang.String.
activeComponents
edit/Player (class org.tynamo.psi.psi.pages.edit.PlayerEdit)
edit/Player:layout (class org.tynamo.psi.psi.components.Layout)
classpath:org/tynamo/psi/psi/pages/edit/PlayerEdit.tml, line 2
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <t:layout title="title" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd" xmlns:p="tapestry:parameter">
3 <p:subMenuBlock>
4 <ul>
5 <ul id="local">
6 </ul>
7 </ul>
edit/Player:form (class org.apache.tapestry5.corelib.components.Form)
classpath:org/tynamo/psi/psi/pages/edit/PlayerEdit.tml, line 17
12
13 <h1>${title}</h1>
14
15 <br/>
16
17 <t:form validate="bean">
18 <t:errors/>
19
20 <div class="t-beaneditor">
21
22 <t:beaneditor object="mb:bean" t:mixins="tynamo/BeanModelAdvisor">
edit/Player:beaneditor (class org.apache.tapestry5.corelib.components.BeanEditor)
classpath:org/tynamo/psi/psi/pages/edit/PlayerEdit.tml, line 22
17 <t:form validate="bean">
18 <t:errors/>
19
20 <div class="t-beaneditor">
21
22 <t:beaneditor object="mb:bean" t:mixins="tynamo/BeanModelAdvisor">
23
24 <p:bio>
25 <t:label for="bio">BIO</t:label>
26 <t:textarea t:id="bio" value="bean.bio" />
27 </p:bio>
edit/Player:beaneditor.loop (class org.apache.tapestry5.corelib.components.Loop)
classpath:org/apache/tapestry5/corelib/components/BeanEditor.tml, line 3
1 <t:loop xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
2 source="model.propertyNames" formState="ITERATION"
3 value="propertyName">
4 <t:propertyEditor property="propertyName" object="object" model="model" overrides="overrides"/>
5 </t:loop>
edit/Player:beaneditor.propertyeditor (class org.apache.tapestry5.corelib.components.PropertyEditor)
classpath:org/apache/tapestry5/corelib/components/BeanEditor.tml, line 4
1 <t:loop xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
2 source="model.propertyNames" formState="ITERATION"
3 value="propertyName">
4 <t:propertyEditor property="propertyName" object="object" model="model" overrides="overrides"/>
5 </t:loop>
tynamo/PropertyEditBlocks:editor (class org.apache.tapestry5.corelib.components.BeanEditor)
classpath:org/tynamo/pages/PropertyEditBlocks.tml, line 58
53 </t:block>
54
55 <t:block id="embedded">
56 <fieldset class="group">
57 <legend>${propertyEditContext.label}</legend>
58 <t:beaneditor t:id="editor" object="propertyEditContext.propertyValue" model="embeddedModel" />
59 </fieldset>
60 </t:block>
61
62 <t:block id="blob">
63 <label>${propertyEditContext.label}</label>
location
classpath:org/tynamo/pages/PropertyEditBlocks.tml, line 58
org.apache.tapestry5.ioc.internal.util.TapestryException
Exception instantiating instance of org.tynamo.psi.psi.model.Demographics (for component 'tynamo/PropertyEditBlocks:editor'): org.apache.tapestry5.ioc.internal.OperationException: No service implements the interface java.lang.String.
location
classpath:org/tynamo/pages/PropertyEditBlocks.tml, line 58
Re: @Embedded properties null not supported in T5.4 ???
Posted by Jonathan Barker <jo...@gmail.com>.
If all of the Embeddable's properties are NULL, Hibernate considers
the object to be null. You can either set your Demographics to a
fresh object before handing the Player to Beaneditor, or make sure
that it doesn't come back null from Hibernate. The easiest way,
though it always smelled bad, was to have a non-NULL dummy property in
Demographics to force Hibernate to create an object. There's probably
a more technically correct Hibernate way, but a dummy property works.
On Sat, Jan 31, 2015 at 1:31 PM, nhhockeyplayer nashua
<nh...@hotmail.com> wrote:
> Folks,
>
> I am wondering if null properties are suppose to be dealt with morwe gracefully within T-5.4 as everytime I create an object it works fine and is displayed within my gallery widget but if I omit property fields declared inside @Embeddable classes, they get stored in hibernate as nulls and any subsequent Edits crash the app due to these omissions. Is tapestry suppose to handle this properly to avoid crash ?
>
> Alleged as follows...
>
> I have a curious EditBlock DisplayBlock issue with regard to entity in hibernate database.
>
> Here is the model layout
>
> I have Person.Java where Person is a base class Player class
>
> But Person.Java has a data member
> private Demographics demographics = new Demographics();
>
> and here is how Demographics is declared
>
> Demographics.Java...
> @Embeddable
> public class Demographics
>
>
> ok so
> Player extends from Person
> Person has demographics
> Player declares the following:
>
> @Column(columnDefinition = "longtext", length = 6291456)
> @PropertyDescriptor(readOnly = false)
> public String getBio() {
> return bio;
> }
>
> My issue is weird... Currently I can create Players at this demo site
> http://psinh.ddns.net:9011/psi/home
>
> If I create a player it gets saved fine
>
> On subsequent EDIT operations (you can edit as player by clicking on any image in Gallery)...
>
> Only Players who's demographics were all filled in with legitimate string data get displayed and edited.
>
> The problem being... the app crashes on Players who's Demographics were omitted on creation and all properties within the @Embedded instance are null.
>
> Its reproducible everytime at http://psinh.ddns.net:9011/psi/home
>
>
> Here is the crash trace
> An exception has occurred processing this request.
> Render queue error in SetupRender[tynamo/PropertyEditBlocks:editor]: Exception instantiating instance of org.tynamo.psi.psi.model.Demographics (for component 'tynamo/PropertyEditBlocks:editor'): org.apache.tapestry5.ioc.internal.OperationException: No service implements the interface java.lang.String.
>
> with reload: Force a reload of component classes. This is often necessary after fixing a class that previously failed to compile due to errors.
> org.apache.tapestry5.internal.services.RenderQueueException
>
> Render queue error in SetupRender[tynamo/PropertyEditBlocks:editor]: Exception instantiating instance of org.tynamo.psi.psi.model.Demographics (for component 'tynamo/PropertyEditBlocks:editor'): org.apache.tapestry5.ioc.internal.OperationException: No service implements the interface java.lang.String.
>
> activeComponents
>
> edit/Player (class org.tynamo.psi.psi.pages.edit.PlayerEdit)
> edit/Player:layout (class org.tynamo.psi.psi.components.Layout)
> classpath:org/tynamo/psi/psi/pages/edit/PlayerEdit.tml, line 2
> 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> 2 <t:layout title="title" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd" xmlns:p="tapestry:parameter">
> 3 <p:subMenuBlock>
> 4 <ul>
> 5 <ul id="local">
> 6 </ul>
> 7 </ul>
> edit/Player:form (class org.apache.tapestry5.corelib.components.Form)
> classpath:org/tynamo/psi/psi/pages/edit/PlayerEdit.tml, line 17
> 12
> 13 <h1>${title}</h1>
> 14
> 15 <br/>
> 16
> 17 <t:form validate="bean">
> 18 <t:errors/>
> 19
> 20 <div class="t-beaneditor">
> 21
> 22 <t:beaneditor object="mb:bean" t:mixins="tynamo/BeanModelAdvisor">
> edit/Player:beaneditor (class org.apache.tapestry5.corelib.components.BeanEditor)
> classpath:org/tynamo/psi/psi/pages/edit/PlayerEdit.tml, line 22
> 17 <t:form validate="bean">
> 18 <t:errors/>
> 19
> 20 <div class="t-beaneditor">
> 21
> 22 <t:beaneditor object="mb:bean" t:mixins="tynamo/BeanModelAdvisor">
> 23
> 24 <p:bio>
> 25 <t:label for="bio">BIO</t:label>
> 26 <t:textarea t:id="bio" value="bean.bio" />
> 27 </p:bio>
> edit/Player:beaneditor.loop (class org.apache.tapestry5.corelib.components.Loop)
> classpath:org/apache/tapestry5/corelib/components/BeanEditor.tml, line 3
> 1 <t:loop xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
> 2 source="model.propertyNames" formState="ITERATION"
> 3 value="propertyName">
> 4 <t:propertyEditor property="propertyName" object="object" model="model" overrides="overrides"/>
> 5 </t:loop>
> edit/Player:beaneditor.propertyeditor (class org.apache.tapestry5.corelib.components.PropertyEditor)
> classpath:org/apache/tapestry5/corelib/components/BeanEditor.tml, line 4
> 1 <t:loop xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
> 2 source="model.propertyNames" formState="ITERATION"
> 3 value="propertyName">
> 4 <t:propertyEditor property="propertyName" object="object" model="model" overrides="overrides"/>
> 5 </t:loop>
> tynamo/PropertyEditBlocks:editor (class org.apache.tapestry5.corelib.components.BeanEditor)
> classpath:org/tynamo/pages/PropertyEditBlocks.tml, line 58
> 53 </t:block>
> 54
> 55 <t:block id="embedded">
> 56 <fieldset class="group">
> 57 <legend>${propertyEditContext.label}</legend>
> 58 <t:beaneditor t:id="editor" object="propertyEditContext.propertyValue" model="embeddedModel" />
> 59 </fieldset>
> 60 </t:block>
> 61
> 62 <t:block id="blob">
> 63 <label>${propertyEditContext.label}</label>
>
> location
> classpath:org/tynamo/pages/PropertyEditBlocks.tml, line 58
>
> org.apache.tapestry5.ioc.internal.util.TapestryException
>
> Exception instantiating instance of org.tynamo.psi.psi.model.Demographics (for component 'tynamo/PropertyEditBlocks:editor'): org.apache.tapestry5.ioc.internal.OperationException: No service implements the interface java.lang.String.
>
> location
> classpath:org/tynamo/pages/PropertyEditBlocks.tml, line 58
>
>
--
Jonathan Barker
ITStrategic
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: @Embedded properties null not supported in T5.4 ???
Posted by Jonathan Barker <jo...@gmail.com>.
I meant have a non-nullable field in Demographics. Such as:
class Demographics {
private int dummy;
public int getDummy(){
return dummy;
}
public void setDummy( int value) {
this.dummy = dummy;
}
}
Because this is a primitive, the "uninitialized" value is "0" and not
NULL, so Hibernate will persist a "0" and force creation of the
Demographics object on retrieval to store that "0".
The problem with what you have is that your constructor sets the value
of demographics to something non-null, and Hibernate comes along and
populates the "correct" null value retrieved from the database. After
all, you don't really have demographics if all of the properties are
null. There are other legitimate cases where you really can have an
embeddable object with all null properties, but I digress.
As I think about it… why not change the getter?
public Demographics getDemographics(){
if (demographics == null)
demographics = new Demographics();
return demographics;
}
It's not what I think of as a getter, but I've done worse things. I'm
not sure if there's a down side to it, but it feels less hack-ish that
polluting your database with useless information. Well, there you
have it, try modifying your getter. It feels less bad.
On Mon, Feb 2, 2015 at 2:46 PM, nhhockeyplayer nashua
<nh...@hotmail.com> wrote:
> Thanks Jonathan.
>
> Person.JAVA
> private Demographics demographics = new Demographics();
>
> is this what you meant? I though this is already sufficient for hibernate because its original code and this worked before so I am wondering why it isnt working now...thats why I felt it was schema issue.
>
>
> Best regards
> and thanks... KEN
>
> From: nhhockeyplayer@hotmail.com
> To: users@tapestry.apache.org
> Subject: RE: @Embedded properties null not supported in T5.4 ???
> Date: Sun, 1 Feb 2015 07:34:00 -0500
>
>
>
>
> this could be a database schema issue
>
> i restored a partial group of entities on this shema from past rev
>
> likely it is that and I should start clean
>
> I wonder what the schema migration semantics are for large scale systems
>
> years ago at Hewlett Packard we operated a fairly commercial one that ran at setup time and overlayed
>
--
Jonathan Barker
ITStrategic
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
RE: @Embedded properties null not supported in T5.4 ???
Posted by nhhockeyplayer nashua <nh...@hotmail.com>.
Thanks Jonathan.
Person.JAVA
private Demographics demographics = new Demographics();
is this what you meant? I though this is already sufficient for hibernate because its original code and this worked before so I am wondering why it isnt working now...thats why I felt it was schema issue.
Best regards
and thanks... KEN
From: nhhockeyplayer@hotmail.com
To: users@tapestry.apache.org
Subject: RE: @Embedded properties null not supported in T5.4 ???
Date: Sun, 1 Feb 2015 07:34:00 -0500
this could be a database schema issue
i restored a partial group of entities on this shema from past rev
likely it is that and I should start clean
I wonder what the schema migration semantics are for large scale systems
years ago at Hewlett Packard we operated a fairly commercial one that ran at setup time and overlayed
RE: @Embedded properties null not supported in T5.4 ???
Posted by nhhockeyplayer nashua <nh...@hotmail.com>.
this could be a database schema issue
i restored a partial group of entities on this shema from past rev
likely it is that and I should start clean
I wonder what the schema migration semantics are for large scale systems
years ago at Hewlett Packard we operated a fairly commercial one that ran at setup time and overlayed