-
-
Save dunst0/02b356f05105d8d07d13 to your computer and use it in GitHub Desktop.
java plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.List; | |
import javax.persistence.PersistenceException; | |
import org.bukkit.plugin.java.JavaPlugin; | |
public class MyPlugin extends JavaPlugin { | |
@Override | |
public void onLoad() { | |
//some more code | |
setupDatabase(); | |
} | |
@Override | |
public List<Class<?>> getDatabaseClasses() { | |
List<Class<?>> classes = super.getDatabaseClasses(); | |
classes.add(ToBeSaved.class); | |
return classes; | |
} | |
private void setupDatabase() { | |
try { | |
getDatabase().find(ToBeSaved.class).findRowCount(); | |
} catch (PersistenceException e) { | |
installDDL(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.avaje.ebean.validation.NotNull; | |
import java.io.Serializable; | |
import javax.persistence.Entity; | |
import javax.persistence.GeneratedValue; | |
import javax.persistence.GenerationType; | |
import javax.persistence.Id; | |
@Entity | |
public class ToBeSaved implements Serializable { | |
private static final long serialVersionUID = 3611041942327901641L; | |
@Id | |
@GeneratedValue(strategy = GenerationType.AUTO) | |
private Long id; | |
@NotNull | |
private String name; | |
public Relation() {} | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public Long getId() { | |
return id; | |
} | |
public void setId(Long id) { | |
this.id = id; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment