Yeah, I think this is a really good idea to support, but like Rafael said, not all databases support this. So the new option you added for this is a good solution I think!<br><br>~Lincoln<br><br><div class="gmail_quote">On Fri, May 4, 2012 at 7:48 AM, George Gastaldi <span dir="ltr">&lt;<a href="mailto:gegastaldi@gmail.com" target="_blank">gegastaldi@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Now I get it. :)<br>
<br>
I always believed that this behavior is related to the supported<br>
features on the database you use.<br>
<br>
For example, if you use an Oracle DB, you can have a sequence for each<br>
table, but that might mean having to place a @SequenceGenerator on<br>
each entity.<br>
<br>
It would be nice to have this feature when creating the JPA entity.<br>
You may want to provide another option in method<br>
org.jboss.forge.spec.javaee.jpa.EntityPlugin.newEntity(String, String)<br>
<br>
Hope that helps,<br>
<div class="HOEnZb"><div class="h5"><br>
George Gastaldi<br>
<br>
2012/5/4 Ryan Bradley &lt;<a href="mailto:rbradley@redhat.com">rbradley@redhat.com</a>&gt;:<br>
&gt; Okay, so say we have two different entities in our scaffolded webapp,<br>
&gt; Customer and Account.  Under the current GenerationStrategy:<br>
&gt;<br>
&gt; I create a Customer object, and that will have an ID of 1.<br>
&gt;<br>
&gt; I create an Account object, and that will have an ID of 2, even though<br>
&gt; it is the first (and only) Account in the database.<br>
&gt;<br>
&gt; Using GenerationStrategy.IDENTITY, both objects will have identities of<br>
&gt; 1, i.e. there are separate sets of IDs kept for each table in the<br>
&gt; database.  One useful case that I can think of is that, in the Spring<br>
&gt; scaffold implementation, individual objects can be navigated to in the<br>
&gt; URL using their ID (e.g. /customers/1 would go to the Customer object in<br>
&gt; the database with an ID of 1).  Therefore, it might cause confusion if a<br>
&gt; user was trying to navigate using the URL but not necessarily knowing<br>
&gt; the ID of the object they are looking for (even if they know its ID<br>
&gt; relative to other objects of the same type).<br>
&gt;<br>
&gt; Does that clarify things?<br>
&gt;<br>
&gt; Cheers,<br>
&gt; Ryan<br>
&gt;<br>
&gt; On 05/04/2012 10:19 AM, George Gastaldi wrote:<br>
&gt;&gt;&gt; Thinking of scaffold implementations, it might be best if a separate set<br>
&gt;&gt;&gt; of IDs was generated for each separate entity.<br>
&gt;&gt; I donīt think I get it. Can you give a practical example ?<br>
&gt;&gt;<br>
&gt;&gt; Regards,<br>
&gt;&gt;<br>
&gt;&gt; George Gastaldi<br>
&gt;&gt;<br>
&gt;&gt; 2012/5/4 Ryan Bradley&lt;<a href="mailto:rbradley@redhat.com">rbradley@redhat.com</a>&gt;:<br>
&gt;&gt;&gt; Greetings all,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Currently, the entity plugin annotates the ID primary key with<br>
&gt;&gt;&gt; @GeneratedValue.  This annotation uses the default generation strategy,<br>
&gt;&gt;&gt; GenerationType.AUTO, to generate the values for this key.  Using this<br>
&gt;&gt;&gt; strategy, the same set of values is used for all entity tables.  In<br>
&gt;&gt;&gt; other words, you cannot have two entities with the same value for ID, as<br>
&gt;&gt;&gt; it is incremented with each entity creation rather than with each<br>
&gt;&gt;&gt; creation of an entity of a specific type.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Thinking of scaffold implementations, it might be best if a separate set<br>
&gt;&gt;&gt; of IDs was generated for each separate entity.  I believe that this can<br>
&gt;&gt;&gt; be accomplished by annotating the field with<br>
&gt;&gt;&gt; @GeneratedValue(strategy=GenerationType.IDENTITY).  I was thinking of<br>
&gt;&gt;&gt; modifying the ScaffoldPlugin to change the GenerationType on this<br>
&gt;&gt;&gt; annotation in the generateFromEntity method (from-entity command).<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Any objections to this change?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Cheers,<br>
&gt;&gt;&gt; Ryan<br>
&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt; forge-dev mailing list<br>
&gt;&gt;&gt; <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; forge-dev mailing list<br>
&gt;&gt; <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
&gt; _______________________________________________<br>
&gt; forge-dev mailing list<br>
&gt; <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
<br>
_______________________________________________<br>
forge-dev mailing list<br>
<a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Lincoln Baxter, III<br><a href="http://ocpsoft.org" target="_blank">http://ocpsoft.org</a><br>&quot;Simpler is better.&quot;<br>