How to bind Vaadin Combobox to PropertyID - combobox

I have a ComboBox with a List of Objects (YFEnum) as a BeanItemContainer. The class looks as follows:
#Entity
#Table(name="ENUM")
public class YFEnum implements Serializable {
#Id
#Column(name="EN_ID")
private int id;
#Column(name="EN_NAME")
private String name;
.....
In my form I would like to bind the ID of the YFEnum-Object via FieldGroup.bindMemberFields to a PropertyID. In my code I tried this as follows, but I know, this cannot work. Unfortunately, I don't know how it could work:
#PropertyId("art")
protected ComboBox cbArt;
The Entity where "art" is a Property looks as follows:
#Entity
#Table(name="PV_EDELMETALL")
#DiscriminatorValue("PVEdelMetall")
public class PVEdelMetall extends ProduktVereinbarung implements Serializable {
#Column(name="PVEM_ART")
protected int art;
....
How can I manage, to get the ID of the selected object (YFEnum) from the ComboBox to the PropertyID "art"?

Related

Android Room - Column conflict on entities that extend a class

I have a Patient entity which extends a base Resource object. Now Resource contains a uuid and a display, which I also want to include to the patients table, so I annotate like so:
public class Resource implements Serializable {
#ColumnInfo
protected String uuid;
#ColumnInfo
protected String display;
// getters and setters
}
And in my Patient entity, there are nested objects and they also extend from Resource (e.g. a PatientIdentifier and a Person object is embedded and has their own uuid and display):
#Entity(tableName = "patients")
public class Patient extends Resource implements Serializable {
#PrimaryKey
private Long id;
// ...
#Embedded
private PatientIdentifier identifier;
#Embedded
private Person person;
// other variables
}
this results in a column name conflict - as there is a "uuid" column for a Patient, the PatientIdentifier and the Person.
I want to rename the nested objects' uuid columns after their name (e.g. "person_uuid"), similar to the #ForeignKey annotation in entity relationships, so may I know how to do that?
You can specify the column name like that :
#ColumnInfo(name = "person_uuid")

#Document(collection = "collectionName") not working when extend another class

I am working on a spring boot application with spring data mongoDB. I have a common class which holds all the common properties and my other classes extend it so that I have those common properties in them.
#Getter
#Setter
#EntityListeners({AuditingEntityListener.class})
public abstract class AbstractAuditEntity implements Serializable {
#CreatedBy
#NotNull
private Long createdBy;
#LastModifiedBy
#NotNull
private Long updatedBy;
#CreatedDate
#NotNull
private Instant createdDate;
#LastModifiedDate
#NotNull
private Instant updatedDate;
}
now when i extend this class in my another class like
#Document(collection = "consumer")
#Data
#AllArgsConstructor
#NoArgsConstructor
#EqualsAndHashCode(callSuper = true)
public class ConsumerEntity extends AbstractAuditEntity {
#Id
private ObjectId id;
}
The document created in mongo database has same name as my class name i.e "ConsumerEntity", how do I get #Document(collection = "consumer") to work so that in my mongo database the collection name is reflected as "consumer". Thank You

Deserialize and access CS:GO JSON array in vb.net

some awesome dude put out the CS:GO skins data out as JSON.
http://api.ncla.me/data/data.json
But I am really struggling to deserialize it and access the individual items.
Could you guys help? Is it possible without third-party additions? ( I don't care how fast or slow it is. )
This is how far I have come
Public Class RootObject
Public Property ResultList_Main As List(Of ListWrapper_Main)
Public Class ListWrapper_Main
Public Property WeaponInfo As List(Of ListWrapper)
End Class
Public Class ListWrapper
Public Property value As String
Public Property quantity As String
End Class
End Class
jsonObject = jsSerializer.Deserialize(Of RootObject)(responseFromServer)
For Each Itemdetail1 In jsonObject.ResultList_Main
For Each Itemdetail2 In Itemdetail1.WeaponInfo
'Would like to display WeaponInfo + Value + Quantity here
Next
Next

MVC3 Model to a database View

I want to create a model on MVC3, but instead of creating a model for a table, I want to create one for a view in my Database. I know that with models for tables, I need to specify primary keys when creating the model, if not i get some error messages. Since views do not have have primary/foreign keys, how do I go about creating models for View?
At any MVC application that works with EF you may have different models to create tables in db or conceptual model for view that doesn't create any tables.Table creation depends on what properties of which model classes you'll define in class that inherited from DbContext. Notice that any property that exists in this class and its relational classes will create table in db. So,to create models that will be used only at view, you can define models that don't have any relationship to other table creator models plus no definition at inherited DbContext class. Then you can use them as model or class to show data at the view.The controller and its related view should use the same model and no errors will be occurred.
public class datacontext : DbContext
{
public DbSet<Person> people { get; set;}
public DbSet<Address> address { get; set;}
}
public class Person
{
[Key]
public int ID { get; set;}
public String Name { get; set;}
}
public class Address
{
[Key]
public int ID { get; set;}
public Country country { get; set;}
public String Details { get; set;}
}
public class Country
{
[Key]
public int ID { get; set;}
public String Name { get; set;}
}
public class Work_Field//without any key definition
{
public String Title { get; set;}
public String Description { get; set;}
}
Here we have this tables : Person, Address, Country(Although it's not defined at datacontext class)
In this example, you can use Work_Field as view model perhaps with some DataAnnotations like [Required],... to force user don't leave parameter empty, and so more.

Twitter like relationships in JPA

I'm getting into problems with JPA. I'm trying to implement a database that allows users to follow other users and be followed.
I think I'd need (summing up) something like this:
USER_TABLE: id | userName
RELATIONSHIP_TABLE: id | follower | followed | acceptation
I have two entities (also summed up):
#Entity
public class User implements Serializable {
#Id
private Long id;
private String userName;
#OneToMany
private Collection<Relationship> followings;
}
#Entity
public class Relationship implements Serializable {
#Id
private Long id;
private User follower;
private User followed;
private boolean accepted;
}
My problem is that I'm not sure if it's possible to do this, because I obtain more tables that the two that I need.
Can anybody help me?
Thanks and sorry about my english.
You obtain more tables because you did not make the associations bidirectional. JPA has no way to know that Relationship.follower is the other side of the User.followings if you don't tell:
#Entity
public class User implements Serializable {
#OneToMany(mappedBy = "follower")
private Collection<Relationship> followings;
// ...
}
#Entity
public class Relationship implements Serializable {
#ManyToOne
#JoinColumn(name = "follower")
private User follower;
#ManyToOne
#JoinColumn(name = "followed")
private User followed;
// ...
}
The documentation of course explains how that works.

Resources