I want to plan a Entities FeatherCoin, who has a good idea ?
-
I want to plan a Entities FeatherCoin, who has a good idea ?
[attachment deleted by admin]
-
Hey there, lizhi! Thanks for posting.
I realize English isn’t your native language, so I wanted to ask for clarification on what you mean by “Entities Feathercoin” and what ideas your looking for specifically. You’re help in getting p2pool working has been great, so I’m interested in what you have in mind here. Can you explain a little more please? Thanks! :)
-
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import org.hibernate.annotations.GenericGenerator;/**
*
* @author RIPPEDDRAGON
*/
@Entity
@NamedQueries({
@NamedQuery(name = “FTC.findAll”, query = “SELECT f FROM FTC f”)})
public class FTC extends Auditable implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GenericGenerator(name=“seq_id”, strategy=“dao.hibernate.SequentialGuidGenerator”)
@GeneratedValue(generator=“seq_id”)
@Basic(optional = false)
private String FTC;public FTC(){
}public FTC(String FTC){
this.FTC = FTC
}
} -
[quote name=“RIPPEDDRAGON” post=“30613” timestamp=“1381167215”]
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import org.hibernate.annotations.GenericGenerator;/**
*
* @author RIPPEDDRAGON
*/
@Entity
@NamedQueries({
@NamedQuery(name = “FTC.findAll”, query = “SELECT f FROM FTC f”)})
public class FTC extends Auditable implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GenericGenerator(name=“seq_id”, strategy=“dao.hibernate.SequentialGuidGenerator”)
@GeneratedValue(generator=“seq_id”)
@Basic(optional = false)
private String FTC;public FTC(){
}public FTC(String FTC){
this.FTC = FTC
}
}
[/quote]Ooooohhhhh… you were so close to having a pure JPA implementation! SO CLOSE!
Can I make a suggestion? Rather than having your database provide your pk, you could do something like this instead:
[code]
@Id
private String FTC = java.util.UUID.randomUUID();
[/code]This has the added benefit of you knowing what your pk will be prior to the insert operation, and it eliminates the dependency on Hibernate.
Other than that, looks good to me!
-
[quote name=“Kevlar” post=“30617” timestamp=“1381169475”]
[quote author=RIPPEDDRAGON link=topic=3945.msg30613#msg30613 date=1381167215]
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import org.hibernate.annotations.GenericGenerator;/**
*
* @author RIPPEDDRAGON
*/
@Entity
@NamedQueries({
@NamedQuery(name = “FTC.findAll”, query = “SELECT f FROM FTC f”)})
public class FTC extends Auditable implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GenericGenerator(name=“seq_id”, strategy=“dao.hibernate.SequentialGuidGenerator”)
@GeneratedValue(generator=“seq_id”)
@Basic(optional = false)
private String FTC;public FTC(){
}public FTC(String FTC){
this.FTC = FTC
}
}
[/quote]Ooooohhhhh… you were so close to having a pure JPA implementation! SO CLOSE!
Can I make a suggestion? Rather than having your database provide your pk, you could do something like this instead:
[code]
@Id
private String FTC = java.util.UUID.randomUUID();
[/code]This has the added benefit of you knowing what your pk will be prior to the insert operation, and it eliminates the dependency on Hibernate.
Other than that, looks good to me!
[/quote]This was more of just a joke using copy/paste/replace from very small segments of my code :P I don’t think this person wants a java entity at all lol.
@GenericGenerator(name=“seq_id”, strategy=“dao.hibernate.SequentialGuidGenerator”) is actually creating custom guids, didn’t feel like adding some custom guid code so just left the full file extension and code out as both need to remain secrets.