You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by George Christman <gc...@cardaddy.com> on 2012/02/27 17:57:14 UTC
Using coposite key with value encoder.
Hello, I'm using hibernate annotations and I also have a db table that
utilizes composite keys. I'm wondering if there is a best practice to get it
to work with a value encoder?
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Using-coposite-key-with-value-encoder-tp5519520p5519520.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Using composite key with value encoder.
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 28 Feb 2012 16:15:17 -0300, George Christman
<gc...@cardaddy.com> wrote:
> Thanks Thiago, this is the method I ended up implementing. I wasn't sure
> if there was a better way of handling this. I'm using a custom component
> that uses a hidden field, do you feel there will be any kind of security
> risk
> publishing the concatenated id in the hidden field, or do you think they
> should be encoded?
As long as they aren't data that can be disclosed (such as credit card
numbers) and your webapp always check if user x is really allowed to make
operation y in object z, I don't think so.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Using composite key with value encoder.
Posted by George Christman <gc...@cardaddy.com>.
Thanks Thiago, this is the method I ended up implementing. I wasn't sure if
there was a better way of handling this. I'm using a custom component that
uses a hidden field, do you feel there will be any kind of security risk
publishing the concatenated id in the hidden field, or do you think they
should be encoded?
On Tue, Feb 28, 2012 at 1:35 PM, Thiago H de Paula Figueiredo [via
Tapestry] <ml...@n5.nabble.com> wrote:
> On Tue, 28 Feb 2012 11:53:43 -0300, Lenny Primak <[hidden email]<http://user/SendEmail.jtp?type=node&node=5522779&i=0>>
>
> wrote:
>
> > Take a look at source code for Tapestry-JPA
>
> Or just think about it: you have an object, two or more values used as
> primary key. Now you need to transform this into a string. Concatenate
> them all using some character. Let's say ':'. Now you have your toClient()
>
> method. For the toValue(), you use string.split(":") and go to the
> database to find the object that has these values as its composite primary
>
> key.
>
> Short version: same as ValueEncoders for simple primary keys, but a little
>
> more complex.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5522779&i=1>
> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5522779&i=2>
>
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://tapestry.1045711.n5.nabble.com/Using-coposite-key-with-value-encoder-tp5519520p5522779.html
> To unsubscribe from Using coposite key with value encoder., click here<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5519520&code=Z2NocmlzdG1hbkBjYXJkYWRkeS5jb218NTUxOTUyMHwxNjMyOTYxMjA3>
> .
> NAML<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
--
George Christman
www.CarDaddy.com
P.O. Box 735
Johnstown, New York
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Using-coposite-key-with-value-encoder-tp5519520p5522915.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
Re: Using composite key with value encoder.
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 28 Feb 2012 11:53:43 -0300, Lenny Primak <lp...@hope.nyc.ny.us>
wrote:
> Take a look at source code for Tapestry-JPA
Or just think about it: you have an object, two or more values used as
primary key. Now you need to transform this into a string. Concatenate
them all using some character. Let's say ':'. Now you have your toClient()
method. For the toValue(), you use string.split(":") and go to the
database to find the object that has these values as its composite primary
key.
Short version: same as ValueEncoders for simple primary keys, but a little
more complex.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Using composite key with value encoder.
Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
Take a look at source code for Tapestry-JPA
On Feb 28, 2012, at 9:14 AM, George Christman wrote:
> Does anybody else have any suggestions on this topic? Unfortunately I'm
> required to use a value encoder in my situation and not sure how to get it
> to work with a composite key. Thanks in advance.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Using composite key with value encoder.
Posted by George Christman <gc...@cardaddy.com>.
Does anybody else have any suggestions on this topic? Unfortunately I'm
required to use a value encoder in my situation and not sure how to get it
to work with a composite key. Thanks in advance.
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Using-coposite-key-with-value-encoder-tp5519520p5521939.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Using coposite key with value encoder.
Posted by George Christman <gc...@cardaddy.com>.
Thanks for informing me of that. I was completely unaware of this behavior
and was able to clean up some code. I do believe I'm still going to need to
the value encoder for my custom component, so would my code sample below
work?
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Using-coposite-key-with-value-encoder-tp5519520p5519711.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Using coposite key with value encoder.
Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
I use JPA, not Hibernate, but I always assumed that Hibernate support is equivalent,
but I don't know that for sure.
On Feb 27, 2012, at 12:43 PM, Robert Zeigler wrote:
> Last time I checked (it's been awhile, I admit :), tapestry-hibernate didn't support composite keys for auto-valueencoder-generation.
>
> Sounds like tapestry-jpa's support is a bit better in that regard. I haven't looked at tapestry-hibernate in 5.3, though; maybe composite key support was added?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Using coposite key with value encoder.
Posted by Robert Zeigler <ro...@roxanemy.com>.
Last time I checked (it's been awhile, I admit :), tapestry-hibernate didn't support composite keys for auto-valueencoder-generation.
Sounds like tapestry-jpa's support is a bit better in that regard. I haven't looked at tapestry-hibernate in 5.3, though; maybe composite key support was added?
Robert
On Feb 27, 2012, at 2/2711:37 AM , Lenny Primak wrote:
> AjaxFormLoop or any other component can be used with Entity beans without any kind of
> custom Value Encoder, as long as they are provided by Tapestry-JPA or Hibernate equivalent.
>
> On Feb 27, 2012, at 12:32 PM, George Christman wrote:
>
>> Oh wow and you don't need to use them for components such as an AjaxFormLoop?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Using coposite key with value encoder.
Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
AjaxFormLoop or any other component can be used with Entity beans without any kind of
custom Value Encoder, as long as they are provided by Tapestry-JPA or Hibernate equivalent.
On Feb 27, 2012, at 12:32 PM, George Christman wrote:
> Oh wow and you don't need to use them for components such as an AjaxFormLoop?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Using coposite key with value encoder.
Posted by George Christman <gc...@cardaddy.com>.
Oh wow and you don't need to use them for components such as an AjaxFormLoop?
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Using-coposite-key-with-value-encoder-tp5519520p5519634.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Using coposite key with value encoder.
Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
I don't have any value encoders at all for my entities. Tapestry-JPA handles it all.
On Feb 27, 2012, at 12:17 PM, George Christman <gc...@cardaddy.com> wrote:
> I set up my entity to use an @EmbeddedId. The @EmbeddedId annotation maps a
> PK class to table PK. See code below, would I just return time.getTimePk();
> in toClient and let the value encoder handle it automatically? Thanks,
> George
>
> @Embeddable
> public class TimePK implements Serializable {
> protected Integer levelStation;
> protected Integer confPathID;
>
> public TimePK() {}
>
> public TimePK(Integer levelStation, String confPathID) {
> this.id = levelStation;
> this.name = confPathID;
> }
> // equals, hashCode
> }
>
> @Entity
> class Time implements Serializable {
> @EmbeddedId
> private TimePK timePK;
>
> private String src;
> private String dst;
> private Integer distance;
> private Integer price;
>
> //...
> }
>
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Using-coposite-key-with-value-encoder-tp5519520p5519594.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Using coposite key with value encoder.
Posted by George Christman <gc...@cardaddy.com>.
I set up my entity to use an @EmbeddedId. The @EmbeddedId annotation maps a
PK class to table PK. See code below, would I just return time.getTimePk();
in toClient and let the value encoder handle it automatically? Thanks,
George
@Embeddable
public class TimePK implements Serializable {
protected Integer levelStation;
protected Integer confPathID;
public TimePK() {}
public TimePK(Integer levelStation, String confPathID) {
this.id = levelStation;
this.name = confPathID;
}
// equals, hashCode
}
@Entity
class Time implements Serializable {
@EmbeddedId
private TimePK timePK;
private String src;
private String dst;
private Integer distance;
private Integer price;
//...
}
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Using-coposite-key-with-value-encoder-tp5519520p5519594.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Using coposite key with value encoder.
Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
I use tapestry-JPA and composite keys work for me automatically. It should work with hibernate the same way I believe. .
On Feb 27, 2012, at 11:57 AM, George Christman <gc...@cardaddy.com> wrote:
> Hello, I'm using hibernate annotations and I also have a db table that
> utilizes composite keys. I'm wondering if there is a best practice to get it
> to work with a value encoder?
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Using-coposite-key-with-value-encoder-tp5519520p5519520.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org