Persistance: Problem with OneToOne Annotation

Discussion in 'Plugin Development' started by MiHo, Jun 7, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    MiHo

    Cause of developing my next plugin I need to use OneToOne Relationships in Persistance, but I can't get working. Sitting infront of my problem for many hours.
    Probably somebody has an idea?

    Exception thrown on startup, when creating the database:
    Code:
    19:37:50 [INFO] [MyResidence] Installing database due to first time usage!
    19:37:50 [INFO] runScript
    19:37:50 [INFO] executing 1 of 18 create table res_players ( id                        integer primary key, name...
    19:37:50 [INFO] executing 2 of 18 create table res_residences ( id                        integer primary key, sig...
    19:37:50 [INFO] executing 3 of 18 create table res_areas ( id                        integer primary key, residenc...
    19:37:50 [INFO] executing 4 of 18 create table res_signs ( id                        integer primary key, residenc...
    19:37:50 [INFO] executing 5 of 18 create table res_towns ( id                        integer primary key, name...
    19:37:50 [INFO] executing 6 of 18 create table res_chunks ( id                        integer primary key, town_id...
    19:37:50 [INFO] executing 7 of 18 alter table res_residences add constraint fk_res_residences_sign_1 foreign key (...
    19:37:50 [INFO] Can not test connection as heartbeatsql is not set
    19:37:50 [INFO] Closing Connection[MyResidence.0] psReuse[0] psCreate[7] psSize[6]
    19:37:50 [INFO] DataSourcePool [MyResidence] grow; id[MyResidence.2] busy[3] max[20]
    19:37:50 [SCHWERWIEGEND] Error occurred while enabling MyResidence v1.0 (Is it up to date?): Error: Error executing stmt[alter table res_residences add constraint fk_res_residences_sign_1 foreign key (sign_id) references res_signs (id)] error[[SQLITE_ERROR] SQL error or missing database (near "constraint": syntax error)]
    javax.persistence.PersistenceException: Error: Error executing stmt[alter table res_residences add constraint fk_res_residences_sign_1 foreign key (sign_id) references res_signs (id)] error[[SQLITE_ERROR] SQL error or missing database (near "constraint": syntax error)]
    	at com.avaje.ebeaninternal.server.ddl.DdlGenerator.runScript(DdlGenerator.java:233)
    	at org.bukkit.plugin.java.JavaPlugin.installDDL(JavaPlugin.java:251)
    	at at.co.hohl.myresidence.listener.MyResidencePlugin.setupDatabase(MyResidencePlugin.java:342)
    	at at.co.hohl.myresidence.listener.MyResidencePlugin.onEnable(MyResidencePlugin.java:80)
    	at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:125)
    	at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:750)
    	at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:253)
    	at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:134)
    	at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:112)
    	at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:232)
    	at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:219)
    	at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:146)
    	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:285)
    	at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)
    Caused by: java.lang.RuntimeException: Error executing stmt[alter table res_residences add constraint fk_res_residences_sign_1 foreign key (sign_id) references res_signs (id)] error[[SQLITE_ERROR] SQL error or missing database (near "constraint": syntax error)]
    	at com.avaje.ebeaninternal.server.ddl.DdlGenerator.runStatement(DdlGenerator.java:281)
    	at com.avaje.ebeaninternal.server.ddl.DdlGenerator.runStatements(DdlGenerator.java:246)
    	at com.avaje.ebeaninternal.server.ddl.DdlGenerator.runScript(DdlGenerator.java:224)
    	... 13 more
    Caused by: java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (near "constraint": syntax error)
    	at org.sqlite.DB.newSQLException(DB.java:383)
    	at org.sqlite.DB.newSQLException(DB.java:387)
    	at org.sqlite.DB.throwex(DB.java:374)
    	at org.sqlite.NativeDB.prepare(Native Method)
    	at org.sqlite.DB.prepare(DB.java:123)
    	at org.sqlite.PrepStmt.<init>(PrepStmt.java:42)
    	at org.sqlite.Conn.prepareStatement(Conn.java:404)
    	at org.sqlite.Conn.prepareStatement(Conn.java:399)
    	at org.sqlite.Conn.prepareStatement(Conn.java:383)
    	at com.avaje.ebeaninternal.server.lib.sql.PooledConnection.prepareStatement(PooledConnection.java:426)
    	at com.avaje.ebeaninternal.server.lib.sql.PooledConnection.prepareStatement(PooledConnection.java:396)
    	at com.avaje.ebeaninternal.server.ddl.DdlGenerator.runStatement(DdlGenerator.java:271)
    	... 15 more
    
    The source of the project could be checked out and build with Maven here: http://www.github.com/hohl/MyResidence

    The file with the OneToOne Relationships is located here: https://github.com/hohl/MyResidence...myresidence/storage/persistent/Residence.java
     
  2. Offline

    masteroftime

    Similar problem already happened to someone else but I cant find the thread now. Anyway the solution is simple:

    You can't use this tag on a sqlite database. Simply change to DBMS to H2 or Mysql and it should work fine.
     
  3. Offline

    MiHo

    AH forgot that thread.
    I found the solution at the other thread already, but thanks.
     
Thread Status:
Not open for further replies.

Share This Page