I have to ask you question about sorting using hibernate, because I absolutely don't know how to resolve my problem, because right now I am on the project, which has been implemented with lot of problems and right know I am standing on one of them.
I have these three model classes.
First one is Document, second one is CustomProperty and the LastOne is CustomPropertyDefinition.
#Indexed
#Table(name = "documents")
#EntityListeners({ AuditingEntityListener.class })
#JsonIgnoreProperties(value = { "isLogicallyDeleted", "textContent", })
public class Document {
#Id
#GeneratedValue(generator = "uuid")
#GenericGenerator(name = "uuid", strategy = "uuid2")
#Column(name = "id", length = 40)
private String id;
#Field
#Column(name = "title", nullable = false)
private String title;
#Field
#Column(name = "mimetype", nullable = false)
private String mimetype;
#Field
#Column(name = "creator")
private String creator;
#Temporal(TemporalType.TIMESTAMP)
#CreatedDate
#Column(name = "created")
private Date created;
#Field
#Column(name = "modifier")
private String modifier;
#Temporal(TemporalType.TIMESTAMP)
#LastModifiedDate
#Column(name = "modified")
private Date modified;
#Field
#Column(name = "folder_id", length = 40)
private String folderId;
#Column(name = "Ordering")
private Date ordering;
#Column(name = "definition_id", length = 40)
private String definitionId;
#OneToMany(mappedBy = "parentDocument", cascade = CascadeType.ALL, orphanRemoval = true)
#JsonManagedReference
private Set<CustomProperty> customProperties = new HashSet<CustomProperty>();
Custom Property :
#Indexed
#Table(name = "custom_properties")
#JsonIgnoreProperties(value = "stringValue")
public class CustomProperty {
#Id
#GeneratedValue(generator = "uuid")
#GenericGenerator(name = "uuid", strategy = "uuid2")
#Column(name = "id", length = 40)
private String id;
#Column(name = "definition_id", nullable = false, length = 40)
private String definitionId;
#Field
#Column(name = "value")
private String stringValue;
#Transient
private String title;
#Transient
private Object value;
#IndexedEmbedded
#ManyToOne
#JoinColumn(name = "document_id", referencedColumnName = "id", updatable = true)
#JsonBackReference
private Document parentDocument;
And CustomPropertyDefinition :
#Entity
#Table(name = "custom_property_definitions")
#JsonIgnoreProperties({ "hibernateLazyInitializer", "definitionsUsedIn" })
public class CustomPropertyDefinition {
#Id
#GeneratedValue(generator = "uuid")
#GenericGenerator(name = "uuid", strategy = "uuid2")
#Column(name = "id", length = 40)
private String id;
#Column(name = "property_type", nullable = false, length = 10)
private String propertyType;
#Column(name = "symbolic_name", unique = true, nullable = false)
private String symbolicName;
#Column(name = "lower_bound")
private String lowerBound;
#Column(name = "upper_bound")
private String upperBound;
#ElementCollection
#CollectionTable(name = "custom_property_definition_allowed_values", joinColumns = #JoinColumn(name = "id"))
#Cascade(CascadeType.ALL)
#Column(name = "allowedValue")
#OrderBy("allowedValue ASC")
private Set<String> allowedValues;
#Transient
private Set<String> allowedValuesToAdd = new HashSet<String>();
#ManyToMany(mappedBy = "customPropertyDefinitions")
private Set<DocumentClassDefinition> definitionsUsedIn;
#ManyToMany(mappedBy = "custPropDefinitions")
private Set<PropertyFolderStructure> propertyFolderStructure;
I am using pagination for returning the documents, but I need to have sorted attribute of Document " CustomProperty " by Attribute of "CustomPropertyDefinition " - > symbolicName . Do you have any idea how to sort it ?
Thank you very much! Every advice for me is great!
Related
Trying to run a delete query on a many-one relationship. But sometime it's stuck for a while when the count of row delete is more then ~50.
Repository:
#Repository
public interface TransitItemRepository extends JpaRepository<TransitItemsMapping, UUID> {
#Modifying
#Transactional
#Query(value="delete from TransitItemsMapping t where t.grouping_form_id=:groupingFormId",nativeQuery = true)
void deleteByGroupingFormId(#Param("groupingFormId") UUID groupingFormId);
}
Domain:TransitItemsMapping.java
#Data
#Entity
#Table(name = "TransitItemsMapping")
public class TransitItemsMapping implements Serializable {
private static final long serialVersionUID = 1L;
#Id
#GenericGenerator(name = "uuid", strategy = "uuid2")
#GeneratedValue(generator = "uuid")
#Column(name = "transit_Item_id",unique = true, nullable = false)
private UUID transitItemId;
#ToString.Exclude
#JsonManagedReference
#JsonIgnore
#ManyToOne(fetch = FetchType.LAZY)
#JoinColumn(name = "grouping_form_id")
//#OnDelete(action = OnDeleteAction.CASCADE)
private GroupingForm groupingForm;
#ManyToOne(fetch = FetchType.EAGER)
#JoinColumn(referencedColumnName = "dim_Item_ID",name = "item_id")
private Item item;
#Column(name ="item_relationship_id", insertable = false,updatable = false)
private String itemRelationshipId;
#ManyToOne(fetch = FetchType.LAZY)
#JoinColumn(name = "item_relationship_id",referencedColumnName = "dim_item_relationship_id")
private VendorFactoryItem vendorFactoryItem;
#Column(name = "edam_id")
private String edamId;
#Column(name = "model_number")
private String modelNumber;
#Column(name = "description")
private String description;
#Column(name = "packaging_details")
private String packagingDetails;
#Column(name = "packaging_method")
private String packagingMethod;
#Column(name = "is_side_stack")
private String isSideStack;
#Column(name = "quantity")
private Integer quantity;
#Column(name = "dimensions")
private String dimensions;
#Column(name = "product_net_weight")
private String productNetWeight;
#Column(name = "plastic_bag_ind")
private String plasticBagInd;
#Column(name = "insertion_order")
private Integer insertionOrder;
#Column(name = "comments")
private String comments;
#Column(name = "item_unique_id")
private String itemUniqueId;
#Column(name = "itm_pak_qty")
private Integer itemPackQuantity;
}
GroupingForm.java
#Setter
#Getter
#NoArgsConstructor
#AllArgsConstructor
#EqualsAndHashCode
#Entity
#Table(name = "GroupingForm")
public class GroupingForm implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
#Id
#GenericGenerator(name = "uuid", strategy = "uuid2")
#GeneratedValue(generator = "uuid")
#Column(name = "grouping_form_id",unique = true, nullable = false)
private UUID groupingFormId;
#Column(name = "grouping_form_name")
private String groupingFormName;
#Column(name = "vid")
private String vid;
#Column(name = "vendor_name")
private String vendorName;
#Column(name = "hovbu")
private String hovbu;
#Column(name = "fid")
private String fid;
#Column(name = "factory_name")
private String factoryName;
#Column(name = "item_count")
private Integer itemCount;
#CreationTimestamp
#Column(name = "creation_date")
private Timestamp creationDate;
#Column(name = "created_by")
private String createdBy;
#UpdateTimestamp
#Column(name = "modified_date")
private Timestamp modifiedDate;
#Column(name = "modified_by")
private String modifiedBy;
#Column(name = "product_engineer")
private String productEngineer;
#Column(name = "status")
private String status;
#Column(name = "sourcing_type")
private String sourcingType;
#Column(name = "total_comments")
private Integer totalComments;
#Column(name = "factory_name_chinese")
private String factoryNameChinese;
#Column(name = "grouping_form_type")
private String groupingFormType;//to save as Product/transit/Product_transit
#Column(name = "ref_id")
private String refId;
#JsonBackReference
#OneToMany(mappedBy = "groupingForm", cascade = CascadeType.ALL)
private List<ProductItemsMapping> productItems = new ArrayList<>();
#JsonBackReference
#OneToMany(mappedBy = "groupingForm", cascade = CascadeType.ALL)
private List<TransitItemsMapping> transitItems = new ArrayList<>();
#Column(name = "pdf_status")
private String pdfStatus;
public GroupingForm(UUID groupingFormId,String groupingFormName, String vid, String vendorName, String hovbu,
String fid, String factoryName, String status, String sourcingType, Integer totalComments,
Date creationDate, String createdBy, Date modifiedDate, String modifiedBy, String productEngineer,
Integer itemCount, String groupingFormType, String refId, String factoryNameChinese) {
this.groupingFormId = groupingFormId;
this.groupingFormName = groupingFormName;
this.vid = vid;
this.vendorName = vendorName;
this.hovbu = hovbu;
this.fid = fid;
this.factoryName = factoryName;
this.status = status;
this.sourcingType = sourcingType;
this.totalComments = totalComments;
this.creationDate = creationDate!=null?new Timestamp(creationDate.getTime()):null;
this.createdBy = createdBy;
this.modifiedDate = modifiedDate!=null?new Timestamp(modifiedDate.getTime()):null;
this.modifiedBy = modifiedBy;
this.productEngineer = productEngineer;
this.itemCount = itemCount;
this.groupingFormType = groupingFormType;
this.refId = refId;
this.factoryNameChinese = factoryNameChinese;
}
}
Service: methods which already annotated with #Transactional
private void updateTransitItem(GroupingCardsDto groupingCardsDto, GroupingForm groupingForm) {
transitItemRepository.deleteByGroupingFormId(groupingCardsDto.getGroupingFormDto().getGroupingFormId());
groupingFormService.saveTransitItems(groupingCardsDto.getGroupingFormDto(), groupingForm);
}
when I am running eclipse in debug mode then my breakpoint is stuck in delete method. I am using
PostgreSQL 9.6.24 on x86_64-pc-linux-gnu, compiled by Debian clang version 12.0.1, 64-bit
version, and for pool connection Hikari-CP-3.2.0.
And If I let my debug running after long time (~45min) I am getting below error.
marked as broken because of SQLSTATE(08006), ErrorCode(0)\norg.postgresql.util.PSQLException: An I/O error occurred while sending to the backend.
Thanks in advance.
There are two possible reasons for this.
Either your delete statement actually takes a really long time, or it is stuck on a lock.
45 min, is certainly a lot for simple delete and could only be expected when you are working on huge amounts of data, like many millions of rows. Use the explain plan to validate that the expected indexes are used.
I consider locks the more likely reason for the problem. You'll need to check what locks are present and where they are coming from. This wiki page about lock monitoring in PostgreSQL seems to be a good starting point.
I want to get all the messages of the all user's subscribers with sql or hql. But i don't know how
I want to create the page with messages of all user's subscribers like in twitter or other social networks
I would appreciate any help
Message entity:
public class Message {
#Id
#GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "msg_seq")
#SequenceGenerator(name = "msg_seq", sequenceName = "msg_seq", initialValue = 1, allocationSize = 1)
#Column(name = "id")
private Integer id;
#Column(name = "text")
private String text;
#Column(name = "tag")
private String tag;
#ManyToOne
#JoinColumn(name = "user_id")
private User author;
#Column(name = "header")
private String header;
#Column(name = "like_count")
private Integer likeCount = 0;
#ManyToMany
#JoinTable(
name = "message_likes",
joinColumns = {#JoinColumn(name = "message_id")},
inverseJoinColumns = {#JoinColumn(name = "user_id")}
)
private Set<User> likes;
#OneToOne
#JoinColumn(name = "file_id")
private FileEntity fileEntity;
}
User entity:
public class User {
#Id
#GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "usr_seq")
#SequenceGenerator(name = "usr_seq", sequenceName = "usr_seq", initialValue = 1, allocationSize = 1)
#Column(name = "id")
private Long id;
#Column(name = "username")
private String username;
#Column(name = "password")
private String password;
#Column(name = "first_name")
private String firstName;
#Column(name = "last_name")
private String lastName;
#Column(name = "role")
private Role role;
#Column(name = "email")
private String email;
#Column(name = "status")
private Status status;
#Column(name = "subscriber_count")
private Integer subscriberCount = 0;
#Column(name = "subscription_count")
private Integer subscriptionCount = 0;
#OneToOne
#JoinColumn(name = "gender_id")
private Gender gender;
#OneToOne
#JoinColumn(name = "address_id")
private Address address;
#ManyToMany
#JoinTable(
name = "user_subscriptions",
joinColumns = #JoinColumn(name = "channel_id"),
inverseJoinColumns = #JoinColumn(name = "subscriber_id"))
private Set<User> subscribers;
#ManyToMany
#JoinTable(
name = "user_subscriptions",
joinColumns = #JoinColumn(name = "subscriber_id"),
inverseJoinColumns = #JoinColumn(name = "channel_id"))
private Set<User> subscriptions;
#OneToOne
#JoinColumn(name = "file_id")
private FileEntity fileEntity;
}
I tried to write this query for my jpa repository but i couldn't
I have a spring data rest api for the backend and AngularJs for the front end (mysql as the DB).
I'm trying to add a list of "dictamenes" to an "expediente" using the repositories I made the following JAVA logic
Mixed Java Class ExpedienteDictamen:
#Entity
#Table(name="expediente_dictamen")
public class ExpedienteDictamen implements Serializable{
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue
#Column(name = "id")
private Long id;
#RestResource(exported=false)
#ManyToOne(fetch = FetchType.EAGER, targetEntity = Expediente.class, optional=false, cascade=CascadeType.MERGE)
#JoinColumns(value = {
#JoinColumn(name = "expediente", referencedColumnName = "id", insertable = true, updatable = true, nullable = true)})
private Expediente expediente;
#RestResource(exported=false)
#ManyToOne(fetch = FetchType.EAGER, targetEntity = Dictamen.class, optional=false, cascade=CascadeType.MERGE)
#JoinColumns(value = {
#JoinColumn(name = "dictamen", referencedColumnName = "id", insertable = true, updatable = true, nullable = true)})
private Dictamen dictamen;
#Column(name = "fecha_carga")
private Date fechaCarga;
#Column(name = "fecha_mod")
private Date fechaMod;
#Column(name = "usuario_carga")
private String usuarioCarga;
#Column(name = "usuario_mod")
private String usuarioMod;
Expediente:
#Entity
#Table(name = "expediente")
public class Expediente implements Serializable {
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue
#Column(name = "id")
private Long id;
#Column(name = "numero_expediente")
private String numeroExpediente;
#Column(name = "acta_recepcion")
private String actaRecepcion;
#Column(name = "acta_aceptacion")
private String actaAceptacion;
#Column(name = "cartilla_medica")
private String cartillaMedica;
#Column(name = "cartilla_medica_obs")
private String cartillaMedicaObs;
#Column(name = "medico_acepta")
private String medicoAcepta;
#Column(name = "cartilla_notificacion")
private String cartillaNotificacion;
#RestResource(exported=false)
#ManyToOne(cascade = {CascadeType.MERGE, CascadeType.PERSIST})
#JoinColumn(name = "solicitud", referencedColumnName = "id")
private Solicitud solicitud;
#RestResource(exported=false)
#ManyToOne(cascade = {CascadeType.MERGE, CascadeType.PERSIST})
#JoinColumn(name = "franquicia", referencedColumnName = "id")
private Franquicia franquicia;
#RestResource(exported=false)
#ManyToOne(cascade = {CascadeType.MERGE, CascadeType.PERSIST})
#JoinColumn(name = "disposicion", referencedColumnName = "id")
private Disposicion disposicion;
#RestResource(exported=false)
#ManyToOne(cascade = {CascadeType.MERGE, CascadeType.PERSIST})
#JoinColumn(name = "paso", referencedColumnName = "id")
private Paso paso;
#OrderBy(value="dictamen")
#RestResource(exported=false)
#OneToMany(fetch = FetchType.EAGER, mappedBy = "expediente", cascade=CascadeType.ALL)
private Set<ExpedienteDictamen> expedienteDictamen = new HashSet<ExpedienteDictamen>();
#Column(name = "obs_documentacion")
private String obsDocumetacion;
#Column(name = "documentacion")
private Boolean documentacion;
#Column(name = "juntamedica")
private Boolean juntamedica;
#Column(name = "visa_rehabilitacion")
private Boolean visaRehabilitacion;
#Column(name = "visa_dos")
private Boolean visaDos;
#Column(name = "mesa_entradas")
private Boolean mesaEntradas;
#Column(name = "direccion_nacional")
private Boolean direccionNacional;
#Column(name = "finalizado")
private Boolean finalizado;
#Column(name = "fecha_carga")
private Date fechaCarga;
#Column(name = "fecha_mod")
private Date fechaMod;
#Column(name = "usuario_carga")
private String usuarioCarga;
#Column(name = "usuario_mod")
private String usuarioMod;
Dictamen:
#Entity
#Table(name = "dictamen")
public class Dictamen implements Serializable {
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue
#Column(name = "id")
private Long id;
#Column(name = "dictamen")
private String dictamen;
#Column(name = "fecha_dictamen")
private Date fechaDictamen;
#Column(name = "numero_dictamen")
private String numeroDictamen;
So far everything but saving a ExpedienteDictamen seems to be working fine.
The repos are standard ones using JpaRepository.
When I post to a existing "ExpedienteDictamen" everything works fine, but when I try to create a new one it says this:
Query is: insert into expediente_dictamen (fecha_carga, fecha_mod, usuario_carga, usuario_mod) values (?, ?, ?, ?)
Query is:
insert into expediente_dictamen (fecha_carga, fecha_mod, usuario_carga, usuario_mod) values (?, ?, ?, ?)
2016-08-30 16:17:01.792 DEBUG 30635 --- [nio-8080-exec-5] a.g.s.f.aop.logging.LoggingAspect : Enter: ar.gob.snr.franquicia.web.rest.errors.ExceptionTranslator.processRuntimeException() with argument[s] = [org.springframework.orm.jpa.JpaSystemException: could not execute statement; nested exception is org.hibernate.exception.GenericJDBCException: could not execute statement]
2016-08-30 16:17:01.792 DEBUG 30635 --- [nio-8080-exec-5] a.g.s.f.aop.logging.LoggingAspect : Exit: ar.gob.snr.franquicia.web.rest.errors.ExceptionTranslator.processRuntimeException() with result = <500 Internal Server Error,ar.gob.snr.franquicia.web.rest.errors.ErrorDTO#6a850e14,{}>
Any Ideas?
**Edited.
How are u creating ExpedienteDictamen without expediente and dictamen values since those are not nullable?
Since these properties also have insertable and updatable as false, records of ExpedienteDictamen could be created using Expediente/Dictamen entities
I'm starting with hibernate and I having some difficulties to build a easy
relationship of tables
, hibernate throw nested exception is org.hibernate.MappingException: Unable to find column with logical name: USERNAME in org.hibernate.mapping.Table(USER_FILESYSTEM) and its related supertables and secondary tables
I have this model
USER--1---N-->USER_FILE_SYSTEM--1--N-->USER_FS_THUMBS
All column name on DB squema are OK the column username" exists on table USER_FILESYSTEM
and table user
Table Users
#Entity
#Table(name = "USERS")
public class Users implements Serializable {
#Id
#Column(name = "USERNAME", nullable = false, length = 15)
private String username;
#Column(name = "PASSWORD", nullable = false, length = 64)
private String password;
#Column(name = "FIRSTNAME", length = 32)
private String firstname;
#Column(name = "LASTNAME", length = 32)
private String lastname;
#Column(name = "EMAIL", nullable = false, length = 60)
private String email;
#Column(name = "TELEPHONE", length = 50)
private String telephone;
#OneToOne(cascade = CascadeType.ALL)
#JoinTable(name = "USER_ROLE",
joinColumns = {
#JoinColumn(name = "USERNAME_ID", referencedColumnName = "USERNAME")},
inverseJoinColumns = {
#JoinColumn(name = "ROL_ID", referencedColumnName = "ROL")}
)
private Rol role;
#OneToMany(
fetch = FetchType.EAGER, mappedBy = "username"
)
private Set<UserFileSystem> fileSystem;
Table UserFileSystem
#Entity
#Table(name = "USER_FILESYSTEM")
public class UserFileSystem implements Serializable {
#Id
#ManyToOne(fetch = FetchType.LAZY)
#JoinColumn(name = "USERNAME", nullable = false)
private Users username;
#Id
#Column(name = "SERVICE_ID", nullable = false, length = 10)
#GeneratedValue(strategy = GenerationType.AUTO)
private Integer serviceId;
#Id
#Column(name = "SERVICE_FOLDER", nullable = false, length = 64)
private String serviceFolder;
#Column(name = "PROTOCOL", length = 20)
private String protocol;
#Column(name = "PARAMS", length = 512)
private String params;
#OneToMany(
fetch = FetchType.LAZY, mappedBy = "userFileSystemThumbsPK"
)
private Set<UserFileSystemThumbs> fileSystemThumbs;
Table UserFileSystemThumbs
#Entity
#Table(name = "USER_FS_THUMBS")
public class UserFileSystemThumbs implements Serializable {
#EmbeddedId
private UserFileSystemThumbsPK userFileSystemThumbsPK;
#Column(name = "SERVICE_URL", nullable = false)
private String serviceUrl;
#Column(name = "CONTENT", nullable = false)
private byte[] content;
#Column(name = "MIME_TYPE", nullable = false)
private String mimeType;
Primary key entity UserFileSystemThumbs
#Embeddable
public class UserFileSystemThumbsPK implements Serializable {
#ManyToOne(fetch = FetchType.LAZY)
#JoinColumns({
#JoinColumn(name = "USERNAME", nullable = false, referencedColumnName = "USERNAME"),
#JoinColumn(name = "SERVICE_ID", nullable = false, referencedColumnName = "SERVICE_ID")
})
private UserFileSystem userFileSystem;
#Column(name = "SERVICE_URL_HASH", nullable = false)
private String serviceUrlHash;
Constructor equals hash....
the problem I think that UserFileSystemThumbsPK USERNAME column do reference to UserFileSystem but in this table the column USERNAME is provided by users.
Solution by OP.
I changed
#Entity
#Table(name = "USER_FILESYSTEM")
public class UserFileSystem implements Serializable {
#Id
#ManyToOne(fetch = FetchType.LAZY)
#JoinColumn(name = "USERNAME", nullable = false)
private Users username;
#Id
#Column(name = "SERVICE_ID", nullable = false, length = 10)
#GeneratedValue(strategy = GenerationType.AUTO)
private Integer serviceId;
}
for this
#Entity
#Table(name = "USER_FILESYSTEM")
public class UserFileSystem implements Serializable {
#EmbeddedId
private UserFileSystemID userFSID;
}
and I created the object UserFileSystemID with 2 values of PK
It's working like a champ!
Would it be possible to declare a HashMap in the following object called Group?
Doing something like this doesn't work:
#OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "group")
#MapKey(name = "member.name")
private Map<String, GroupMember> groupMembers = new HashMap<String, GroupMember>();
StackTrace:
12:07:51 [INFO] [Groups] Enabling Groups v0.1
12:07:51 [SEVERE] Error occurred while enabling Groups v0.1 (Is it up to date?)
java.lang.RuntimeException: An exception has occured while initializing the database
at groups.storage.MyDatabase.initializeDatabase(MyDatabase.java:83)
at groups.storage.Dao.<init>(Dao.java:26)
at groups.Groups.onEnable(Groups.java:30)
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217)
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:457)
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:381)
at org.bukkit.craftbukkit.v1_5_R2.CraftServer.loadPlugin(CraftServer.java:282)
at org.bukkit.craftbukkit.v1_5_R2.CraftServer.enablePlugins(CraftServer.java:264)
at org.bukkit.craftbukkit.v1_5_R2.CraftServer.reload(CraftServer.java:605)
at org.bukkit.Bukkit.reload(Bukkit.java:184)
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:23)
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:188)
at org.bukkit.craftbukkit.v1_5_R2.CraftServer.dispatchCommand(CraftServer.java:523)
at org.bukkit.craftbukkit.v1_5_R2.CraftServer.dispatchServerCommand(CraftServer.java:512)
at net.minecraft.server.v1_5_R2.DedicatedServer.am(DedicatedServer.java:261)
at net.minecraft.server.v1_5_R2.DedicatedServer.r(DedicatedServer.java:226)
at net.minecraft.server.v1_5_R2.MinecraftServer.q(MinecraftServer.java:474)
at net.minecraft.server.v1_5_R2.MinecraftServer.run(MinecraftServer.java:407)
at net.minecraft.server.v1_5_R2.ThreadServerApplication.run(SourceFile:573)
Caused by: java.lang.RuntimeException: Failed to create a new instance of the EbeanServer
at groups.storage.MyDatabase.loadDatabase(MyDatabase.java:162)
at groups.storage.MyDatabase.initializeDatabase(MyDatabase.java:77)
... 18 more
Caused by: javax.persistence.PersistenceException: groups.model.Group: Could not find mapKey property [member.name] on [groups.model.GroupMember]
at com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocMany.initMapKeyProperty(BeanPropertyAssocMany.java:744)
at com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocMany.initialise(BeanPropertyAssocMany.java:147)
at com.avaje.ebeaninternal.server.deploy.BeanDescriptor.initialiseOther(BeanDescriptor.java:763)
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.initialiseAll(BeanDescriptorManager.java:403)
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.deploy(BeanDescriptorManager.java:293)
at com.avaje.ebeaninternal.server.core.InternalConfiguration.<init>(InternalConfiguration.java:150)
at com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:209)
at com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:64)
at com.avaje.ebean.EbeanServerFactory.create(EbeanServerFactory.java:78)
at groups.storage.MyDatabase.loadDatabase(MyDatabase.java:159)
... 19 more
...
#Entity
#Table(name = "groups_group")
public class Group {
public enum Type {
Include,
Exclude
}
#Id
#GeneratedValue
#Column(name = "id", unique = true, nullable = false)
private Integer id;
#Column(name = "name", unique = true, nullable = false, length = 25)
private String name;
#OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "group")
#MapKey(name = "member.name")
private Map<String, GroupMember> groupMembers = new HashMap<String, GroupMember>();
#Column(name = "personal", nullable = false)
private Boolean personal = false;
#Enumerated(value = EnumType.ORDINAL)
#Column(name = "type", nullable = false, length = 2)
private Type type = Type.Include;
#Column(name = "password", nullable = true, length = 16)
private String password;
#Version
#Column(name = "update_time", nullable = false)
Timestamp updatetime;
#CreatedTimestamp
#Column(name = "create_time", nullable = false)
Timestamp createTime;
public Group() {}
//getters and setters
}
..
#Entity
#Table(name = "groups_group_member")
public class GroupMember {
public enum Role {
ADMIN,
MODERATOR,
MEMBER,
BANNED
}
#Id
#GeneratedValue
#Column(name = "id", unique = true, nullable = false)
private Integer id;
#ManyToOne
#JoinColumn(name = "group_id")
private Group group;
#ManyToOne
#JoinColumn(name = "member_id")
private Member member;
#Enumerated(value = EnumType.ORDINAL)
#Column(name = "role", nullable = false, length = 2)
private Role role = Role.MEMBER;
#Version
#Column(name = "update_time", nullable = false)
Timestamp updatetime;
#CreatedTimestamp
#Column(name = "create_time", nullable = false)
Timestamp createTime;
public GroupMember() {}
//getters and setters...
}
...
#Entity
#Table(name = "groups_member")
public class Member {
#Id
#GeneratedValue
#Column(name = "id", unique = true, nullable = false)
private Integer id;
#Column(name = "name", unique = true, nullable = false, length = 16)
private String name;
#OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "member")
private Set<GroupMember> groupMembers = new HashSet<GroupMember>();
#Version
#Column(name = "update_time", nullable = false)
Timestamp updatetime;
#CreatedTimestamp
#Column(name = "create_time", nullable = false)
Timestamp createTime;
public Member() {}
//getters and setters
}