Bit weird but to reply to myself:

On 5 September 2011 11:32, Jasha Joachimsthal
<[email protected]>wrote:

> Hi,
>
> So far Rave has only used the in memory H2 database. I want to configure
> Rave to use a MySQL database. The sequence generation annotation we use is
> not compatible with MySQL.
>
> As an example the o.a.r.portal.model.Page:
> @SequenceGenerator(name="pageIdSeq", sequenceName = "page_id_seq")
> /* ... */
> public class Page implements BasicEntity, Serializable {
> /* ... */
> @Id @Column(name="id")
> @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "pageIdSeq"
> private Long id;
>
> This is the kind of error you get:
>
> Error instantiating named sequence "page_id_seq": Your database dictionary 
> does not support native sequences.  To tell the dictionary how to select 
> sequence values, use:
> openjpa.jdbc.DBDictionary: NextSequenceQuery="SELECT NEXT VALUE FOR 
> "page_id_seq"
>
> One way to solve this is to create a orm.xml file that overrides the
> GeneratedValue strategy:
>   <entity class="org.apache.rave.portal.model.Page">
>     <attributes>
>       <id name="id">
>         <generated-value strategy="SEQUENCE" generator=""/>
>

This should be strategy="IDENTITY" to use the autoincrement in MySQL


>        </id>
>     </attributes>
> </entity>
>
> But this means that if you want to deploy Rave against a MySQL database you
> have to check all the beans if they use the @SequenceGenerator and update
> your orm.xml.
>

Plus that for some unknown reason it doesn't work as expected. The database
schema is created, all tables have an autoincrement id field, which means
the generated-value from the orm.xml has been read and used. However when I
want to add a new user, I get the following error:
"<openjpa-2.1.1-r422266:1148538 fatal user error>
org.apache.openjpa.persistence.ArgumentException: Error instantiating named
sequence "user_id_seq": Your database dictionary does not support native
sequences.  To tell the dictionary how to select sequence values, use:
openjpa.jdbc.DBDictionary: NextSequenceQuery="SELECT NEXT VALUE FOR
"user_id_seq"
Where the above string is replaced with the proper SQL for your database."

This is strange because during creation of the schema it used the orm.xml
but when the entitymanager persists, it suddenly falls back to the
annotation. I created a sample app but haven't found this behaviour. I'm a
bit clueless now.



>
> Another way is to remove the @SequenceGenerator and the reference in
> @GeneratedValue (generator="...")
>
> Is there a reason why we explicitly specify the @SequenceGenerator? If not,
> can we remove this from all the beans that use it?
>

The H2 demo content doesn't load (and all tests fail) if the strategy is set
to INCREMENT.

Has someone else successfully run Rave against a different DB than H2
(preferably MySQL)?

Jasha

Reply via email to