なぜjpaリポジトリが同じクエリをEclipseコンソールに書き込むのですか? テーマをたくさん勉強していますか?jpaリポジトリ/ Hibernateが同じクエリをコンソールに書き込む理由
Hibernate: select technicald0_.CTC_ID as CTC_ID1_7_0_, technicald0_.CTC_PANIER_CLASSIF as CTC_PANI9_7_0_, technicald0_.CTC_PANIER_STAT as CTC_PAN10_7_0_, technicald0_.VEH_COMMENTAIRE_TECH as VEH_COMM2_7_0_, technicald0_.CTC_NBR_DIFFUS as CTC_NBR_3_7_0_, technicald0_.VEH_GENERATION_TECH as VEH_GENE4_7_0_, technicald0_.CTC_DATE_MODIFICATION as CTC_DATE5_7_0_, technicald0_.CTC_MODIFICATEUR_ID as CTC_MOD11_7_0_, technicald0_.VEH_PHASE as VEH_PHAS6_7_0_, technicald0_.VEH_ETAT as VEH_ETAT7_7_0_, technicald0_.VEH_PONDERATION as VEH_POND8_7_0_ from SRA_COTA_TECHNIQUES technicald0_ where technicald0_.CTC_ID=?
Hibernate: select technicald0_.CTC_ID as CTC_ID1_7_0_, technicald0_.CTC_PANIER_CLASSIF as CTC_PANI9_7_0_, technicald0_.CTC_PANIER_STAT as CTC_PAN10_7_0_, technicald0_.VEH_COMMENTAIRE_TECH as VEH_COMM2_7_0_, technicald0_.CTC_NBR_DIFFUS as CTC_NBR_3_7_0_, technicald0_.VEH_GENERATION_TECH as VEH_GENE4_7_0_, technicald0_.CTC_DATE_MODIFICATION as CTC_DATE5_7_0_, technicald0_.CTC_MODIFICATEUR_ID as CTC_MOD11_7_0_, technicald0_.VEH_PHASE as VEH_PHAS6_7_0_, technicald0_.VEH_ETAT as VEH_ETAT7_7_0_, technicald0_.VEH_PONDERATION as VEH_POND8_7_0_ from SRA_COTA_TECHNIQUES technicald0_ where technicald0_.CTC_ID=?
Hibernate: select technicald0_.CTC_ID as CTC_ID1_7_0_, technicald0_.CTC_PANIER_CLASSIF as CTC_PANI9_7_0_, technicald0_.CTC_PANIER_STAT as CTC_PAN10_7_0_, technicald0_.VEH_COMMENTAIRE_TECH as VEH_COMM2_7_0_, technicald0_.CTC_NBR_DIFFUS as CTC_NBR_3_7_0_, technicald0_.VEH_GENERATION_TECH as VEH_GENE4_7_0_, technicald0_.CTC_DATE_MODIFICATION as CTC_DATE5_7_0_, technicald0_.CTC_MODIFICATEUR_ID as CTC_MOD11_7_0_, technicald0_.VEH_PHASE as VEH_PHAS6_7_0_, technicald0_.VEH_ETAT as VEH_ETAT7_7_0_, technicald0_.VEH_PONDERATION as VEH_POND8_7_0_ from SRA_COTA_TECHNIQUES technicald0_ where technicald0_.CTC_ID=?
Hibernate: select technicald0_.CTC_ID as CTC_ID1_7_0_, technicald0_.CTC_PANIER_CLASSIF as CTC_PANI9_7_0_, technicald0_.CTC_PANIER_STAT as CTC_PAN10_7_0_, technicald0_.VEH_COMMENTAIRE_TECH as VEH_COMM2_7_0_, technicald0_.CTC_NBR_DIFFUS as CTC_NBR_3_7_0_, technicald0_.VEH_GENERATION_TECH as VEH_GENE4_7_0_, technicald0_.CTC_DATE_MODIFICATION as CTC_DATE5_7_0_, technicald0_.CTC_MODIFICATEUR_ID as CTC_MOD11_7_0_, technicald0_.VEH_PHASE as VEH_PHAS6_7_0_, technicald0_.VEH_ETAT as VEH_ETAT7_7_0_, technicald0_.VEH_PONDERATION as VEH_POND8_7_0_ from SRA_COTA_TECHNIQUES technicald0_ where technicald0_.CTC_ID=?
Hibernate: select technicald0_.CTC_ID as CTC_ID1_7_0_, technicald0_.CTC_PANIER_CLASSIF as CTC_PANI9_7_0_, technicald0_.CTC_PANIER_STAT as CTC_PAN10_7_0_, technicald0_.VEH_COMMENTAIRE_TECH as VEH_COMM2_7_0_, technicald0_.CTC_NBR_DIFFUS as CTC_NBR_3_7_0_, technicald0_.VEH_GENERATION_TECH as VEH_GENE4_7_0_, technicald0_.CTC_DATE_MODIFICATION as CTC_DATE5_7_0_, technicald0_.CTC_MODIFICATEUR_ID as CTC_MOD11_7_0_, technicald0_.VEH_PHASE as VEH_PHAS6_7_0_, technicald0_.VEH_ETAT as VEH_ETAT7_7_0_, technicald0_.VEH_PONDERATION as VEH_POND8_7_0_ from SRA_COTA_TECHNIQUES technicald0_ where technicald0_.CTC_ID=?
Hibernate: select technicald0_.CTC_ID as CTC_ID1_7_0_, technicald0_.CTC_PANIER_CLASSIF as CTC_PANI9_7_0_, technicald0_.CTC_PANIER_STAT as CTC_PAN10_7_0_, technicald0_.VEH_COMMENTAIRE_TECH as VEH_COMM2_7_0_, technicald0_.CTC_NBR_DIFFUS as CTC_NBR_3_7_0_, technicald0_.VEH_GENERATION_TECH as VEH_GENE4_7_0_, technicald0_.CTC_DATE_MODIFICATION as CTC_DATE5_7_0_, technicald0_.CTC_MODIFICATEUR_ID as CTC_MOD11_7_0_, technicald0_.VEH_PHASE as VEH_PHAS6_7_0_, technicald0_.VEH_ETAT as VEH_ETAT7_7_0_, technicald0_.VEH_PONDERATION as VEH_POND8_7_0_ from SRA_COTA_TECHNIQUES technicald0_ where technicald0_.CTC_ID=?
Hibernate: select technicald0_.CTC_ID as CTC_ID1_7_0_, technicald0_.CTC_PANIER_CLASSIF as CTC_PANI9_7_0_, technicald0_.CTC_PANIER_STAT as CTC_PAN10_7_0_, technicald0_.VEH_COMMENTAIRE_TECH as VEH_COMM2_7_0_, technicald0_.CTC_NBR_DIFFUS as CTC_NBR_3_7_0_, technicald0_.VEH_GENERATION_TECH as VEH_GENE4_7_0_, technicald0_.CTC_DATE_MODIFICATION as CTC_DATE5_7_0_, technicald0_.CTC_MODIFICATEUR_ID as CTC_MOD11_7_0_, technicald0_.VEH_PHASE as VEH_PHAS6_7_0_, technicald0_.VEH_ETAT as VEH_ETAT7_7_0_, technicald0_.VEH_PONDERATION as VEH_POND8_7_0_ from SRA_COTA_TECHNIQUES technicald0_ where technicald0_.CTC_ID=?
Hibernate: select technicald0_.CTC_ID as CTC_ID1_7_0_, technicald0_.CTC_PANIER_CLASSIF as CTC_PANI9_7_0_, technicald0_.CTC_PANIER_STAT as CTC_PAN10_7_0_, technicald0_.VEH_COMMENTAIRE_TECH as VEH_COMM2_7_0_, technicald0_.CTC_NBR_DIFFUS as CTC_NBR_3_7_0_, technicald0_.VEH_GENERATION_TECH as VEH_GENE4_7_0_, technicald0_.CTC_DATE_MODIFICATION as CTC_DATE5_7_0_, technicald0_.CTC_MODIFICATEUR_ID as CTC_MOD11_7_0_, technicald0_.VEH_PHASE as VEH_PHAS6_7_0_, technicald0_.VEH_ETAT as VEH_ETAT7_7_0_, technicald0_.VEH_PONDERATION as VEH_POND8_7_0_ from SRA_COTA_TECHNIQUES technicald0_ where technicald0_.CTC_ID=?
Hibernate: select technicald0_.CTC_ID as CTC_ID1_7_0_, technicald0_.CTC_PANIER_CLASSIF as CTC_PANI9_7_0_, technicald0_.CTC_PANIER_STAT as CTC_PAN10_7_0_, technicald0_.VEH_COMMENTAIRE_TECH as VEH_COMM2_7_0_, technicald0_.CTC_NBR_DIFFUS as CTC_NBR_3_7_0_, technicald0_.VEH_GENERATION_TECH as VEH_GENE4_7_0_, technicald0_.CTC_DATE_MODIFICATION as CTC_DATE5_7_0_, technicald0_.CTC_MODIFICATEUR_ID as CTC_MOD11_7_0_, technicald0_.VEH_PHASE as VEH_PHAS6_7_0_, technicald0_.VEH_ETAT as VEH_ETAT7_7_0_, technicald0_.VEH_PONDERATION as VEH_POND8_7_0_ from SRA_COTA_TECHNIQUES technicald0_ where technicald0_.CTC_ID=?
Hibernate: select technicald0_.CTC_ID as CTC_ID1_7_0_, technicald0_.CTC_PANIER_CLASSIF as CTC_PANI9_7_0_, technicald0_.CTC_PANIER_STAT as CTC_PAN10_7_0_, technicald0_.VEH_COMMENTAIRE_TECH as VEH_COMM2_7_0_, technicald0_.CTC_NBR_DIFFUS as CTC_NBR_3_7_0_, technicald0_.VEH_GENERATION_TECH as VEH_GENE4_7_0_, technicald0_.CTC_DATE_MODIFICATION as CTC_DATE5_7_0_, technicald0_.CTC_MODIFICATEUR_ID as CTC_MOD11_7_0_, technicald0_.VEH_PHASE as VEH_PHAS6_7_0_, technicald0_.VEH_ETAT as VEH_ETAT7_7_0_, technicald0_.VEH_PONDERATION as VEH_POND8_7_0_ from SRA_COTA_TECHNIQUES technicald0_ where technicald0_.CTC_ID=?
Hibernate: select technicald0_.CTC_ID as CTC_ID1_7_0_, technicald0_.CTC_PANIER_CLASSIF as CTC_PANI9_7_0_, technicald0_.CTC_PANIER_STAT as CTC_PAN10_7_0_, technicald0_.VEH_COMMENTAIRE_TECH as VEH_COMM2_7_0_, technicald0_.CTC_NBR_DIFFUS as CTC_NBR_3_7_0_, technicald0_.VEH_GENERATION_TECH as VEH_GENE4_7_0_, technicald0_.CTC_DATE_MODIFICATION as CTC_DATE5_7_0_, technicald0_.CTC_MODIFICATEUR_ID as CTC_MOD11_7_0_, technicald0_.VEH_PHASE as VEH_PHAS6_7_0_, technicald0_.VEH_ETAT as VEH_ETAT7_7_0_, technicald0_.VEH_PONDERATION as VEH_POND8_7_0_ from SRA_COTA_TECHNIQUES technicald0_ where technicald0_.CTC_ID=?
Hibernate: select technicald0_.CTC_ID as CTC_ID1_7_0_, technicald0_.CTC_PANIER_CLASSIF as CTC_PANI9_7_0_, technicald0_.CTC_PANIER_STAT as CTC_PAN10_7_0_, technicald0_.VEH_COMMENTAIRE_TECH as VEH_COMM2_7_0_, technicald0_.CTC_NBR_DIFFUS as CTC_NBR_3_7_0_, technicald0_.VEH_GENERATION_TECH as VEH_GENE4_7_0_, technicald0_.CTC_DATE_MODIFICATION as CTC_DATE5_7_0_, technicald0_.CTC_MODIFICATEUR_ID as CTC_MOD11_7_0_, technicald0_.VEH_PHASE as VEH_PHAS6_7_0_, technicald0_.VEH_ETAT as VEH_ETAT7_7_0_, technicald0_.VEH_PONDERATION as VEH_POND8_7_0_ from SRA_COTA_TECHNIQUES technicald0_ where technicald0_.CTC_ID=?
Hibernate: select technicald0_.CTC_ID as CTC_ID1_7_0_, technicald0_.CTC_PANIER_CLASSIF as CTC_PANI9_7_0_, technicald0_.CTC_PANIER_STAT as CTC_PAN10_7_0_, technicald0_.VEH_COMMENTAIRE_TECH as VEH_COMM2_7_0_, technicald0_.CTC_NBR_DIFFUS as CTC_NBR_3_7_0_, technicald0_.VEH_GENERATION_TECH as VEH_GENE4_7_0_, technicald0_.CTC_DATE_MODIFICATION as CTC_DATE5_7_0_, technicald0_.CTC_MODIFICATEUR_ID as CTC_MOD11_7_0_, technicald0_.VEH_PHASE as VEH_PHAS6_7_0_, technicald0_.VEH_ETAT as VEH_ETAT7_7_0_, technicald0_.VEH_PONDERATION as VEH_POND8_7_0_ from SRA_COTA_TECHNIQUES technicald0_ where technicald0_.CTC_ID=?
Hibernate: select technicald0_.CTC_ID as CTC_ID1_7_0_, technicald0_.CTC_PANIER_CLASSIF as CTC_PANI9_7_0_, technicald0_.CTC_PANIER_STAT as CTC_PAN10_7_0_, technicald0_.VEH_COMMENTAIRE_TECH as VEH_COMM2_7_0_, technicald0_.CTC_NBR_DIFFUS as CTC_NBR_3_7_0_, technicald0_.VEH_GENERATION_TECH as VEH_GENE4_7_0_, technicald0_.CTC_DATE_MODIFICATION as CTC_DATE5_7_0_, technicald0_.CTC_MODIFICATEUR_ID as CTC_MOD11_7_0_, technicald0_.VEH_PHASE as VEH_PHAS6_7_0_, technicald0_.VEH_ETAT as VEH_ETAT7_7_0_, technicald0_.VEH_PONDERATION as VEH_POND8_7_0_ from SRA_COTA_TECHNIQUES technicald0_ where technicald0_.CTC_ID=?
Hibernate: select technicald0_.CTC_ID as CTC_ID1_7_0_, technicald0_.CTC_PANIER_CLASSIF as CTC_PANI9_7_0_, technicald0_.CTC_PANIER_STAT as CTC_PAN10_7_0_, technicald0_.VEH_COMMENTAIRE_TECH as VEH_COMM2_7_0_, technicald0_.CTC_NBR_DIFFUS as CTC_NBR_3_7_0_, technicald0_.VEH_GENERATION_TECH as VEH_GENE4_7_0_, technicald0_.CTC_DATE_MODIFICATION as CTC_DATE5_7_0_, technicald0_.CTC_MODIFICATEUR_ID as CTC_MOD11_7_0_, technicald0_.VEH_PHASE as VEH_PHAS6_7_0_, technicald0_.VEH_ETAT as VEH_ETAT7_7_0_, technicald0_.VEH_PONDERATION as VEH_POND8_7_0_ from SRA_COTA_TECHNIQUES technicald0_ where technicald0_.CTC_ID=?
私のクエリがあるのです:
Cart findByRefVehicle(VehicleFinalized one);
私は、TechnicalData
にTechnicalDataとVehicleFinalizedへカートbeetween関係私のエンティティクラスがあるがカートクラス& & VehicleFinalzedクラス& & TechnicalDataクラスがありますしています:
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.NamedAttributeNode;
import javax.persistence.NamedEntityGraph;
import javax.persistence.NamedEntityGraphs;
import javax.persistence.NamedSubgraph;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.transaction.NotSupportedException;
import com.normasys.entity.reference.Brand;
import com.normasys.entity.reference.Model;
import com.normasys.entity.technical.TechnicalData;
@SuppressWarnings("serial")
@Entity
@Table(name = "SRA_VEHICULE_FIN", uniqueConstraints = { @UniqueConstraint(name = "UNIQUE_VEH_FIN_SRA", columnNames = { "VEH_CODE_SRA" }) })
@DiscriminatorValue(Environment.FINAL)
@NamedEntityGraphs({
@NamedEntityGraph(name = "VehicleFinalized.full", attributeNodes = { @NamedAttributeNode("bodywork"), @NamedAttributeNode("supply"),
@NamedAttributeNode("energy"), @NamedAttributeNode("price"), @NamedAttributeNode("classification"), @NamedAttributeNode("identification"),
@NamedAttributeNode("motorization"), @NamedAttributeNode("suspensionAndBraking"), @NamedAttributeNode("dimensionAndWeight"),
@NamedAttributeNode("securityElement"), @NamedAttributeNode("drivingAssistance") },
subclassSubgraphs = @NamedSubgraph(name = "VehicleFinalized.full.model", attributeNodes = { @NamedAttributeNode("brand") })),
@NamedEntityGraph(name = "VehicleFinalized.properties_only", attributeNodes = { @NamedAttributeNode("bodywork"), @NamedAttributeNode("supply"),
@NamedAttributeNode("energy") }) })
public class VehicleFinalized extends AbstractVehicle {
// private static final Logger LOGGER = Logger.getLogger(VehiculeFinalized.class);
@JoinColumn(name = "VEH_CREATE_FROM", nullable = true, foreignKey = @ForeignKey(name = "FK_VEH_FIN_CRF"))
@OneToOne(fetch = FetchType.LAZY, optional = true, orphanRemoval = true)
private Vehicle createdFrom;
@Column(name = "VEH_CODE_SRA", length = 7, nullable = false, unique = true)
private String codeSRA;
@Column(name = "VEH_NUM_ORDRE", nullable = false)
private Integer orderNumber;
@Column(name = "VEH_CODE_SEQUENCE")
private Integer sequenceCode;
@JoinColumn(name = "VEH_PRIX_COUT", nullable = false, foreignKey = @ForeignKey(name = "FK_VEH_FIN_PCF"))
@OneToOne(fetch = FetchType.EAGER, optional = false, orphanRemoval = true, cascade = CascadeType.ALL)
protected PriceFinalized price = new PriceFinalized();
@JoinColumn(name = "VEH_CLASSIFICATION", nullable = false, foreignKey = @ForeignKey(name = "FK_VEH_FIN_CLS"))
@OneToOne(fetch = FetchType.EAGER, optional = false, orphanRemoval = true, cascade = CascadeType.ALL)
protected ClassificationFinalized classification = new ClassificationFinalized();
@JoinColumn(name = "VEH_DONNEE_TECHNIQUE", nullable = false, foreignKey = @ForeignKey(name = "FK_VEH_FIN_CTC"))
@OneToOne(fetch = FetchType.EAGER, optional = false, orphanRemoval = true, cascade = { CascadeType.PERSIST, CascadeType.DETACH, CascadeType.REFRESH,
CascadeType.REMOVE })
protected TechnicalData technicalData = new TechnicalData();
public VehicleFinalized() {
}
public VehicleFinalized(final VehicleFinalized vehicle) {
environment = Environment.FINAL;
createdFrom = vehicle.getCreatedFrom();
codeSRA = vehicle.getCodeSRA();
orderNumber = vehicle.getOrderNumber();
sequenceCode = vehicle.getSequenceCode();
price = vehicle.getPrice().clone();
classification = vehicle.getClassification().clone();
technicalData = vehicle.getTechnicalData().clone();
copyFields(vehicle);
}
public VehicleFinalized(final Vehicle vehicle, final Integer sequenceCode, final Integer orderNumber) throws NotSupportedException {
createdFrom = vehicle;
environment = Environment.FINAL;
this.sequenceCode = sequenceCode;
this.orderNumber = orderNumber;
copyFields(vehicle);
codeSRA = VehicleFinalizedUtil.generateCodeSRA(model.getBrand().getCode(), model.getCode(), sequenceCode);
price = new PriceFinalized(vehicle.getPrice());
classification = new ClassificationFinalized(vehicle.getClassification());
}
public VehicleFinalized(final Long id, final String codeSRA, final String model, final String brand) {
super();
setId(id);
this.codeSRA = codeSRA;
this.model = new Model();
this.model.setTitle(model);
this.model.setBrand(new Brand());
this.model.getBrand().setTitle(brand);
}
@Override
public boolean calculateCompleted() {
return uncompleted == 0 || getBrand() != null && model != null && bodywork != null && supply != null && energy != null && version != null
&& administrativePower != null
&& identification.calculateCompleted() && motorization.calculateCompleted() && suspensionAndBraking.calculateCompleted()
&& dimensionAndWeight.calculateCompleted() && securityElement.calculateCompleted() && price.calculateCompleted()
&& classification.calculateCompleted() && drivingAssistance.calculateCompleted();
}
public Vehicle getCreatedFrom() {
return createdFrom;
}
public void setCreatedFrom(final Vehicle createdFrom) {
this.createdFrom = createdFrom;
}
public String getCodeSRA() {
return codeSRA;
}
public void setCodeSRA(final String codeSRA) {
this.codeSRA = codeSRA;
}
public Integer getOrderNumber() {
return orderNumber;
}
public void setOrderNumber(final Integer orderNumber) {
this.orderNumber = orderNumber;
}
@Override
public PriceFinalized getPrice() {
return price;
}
public void setPrice(final PriceFinalized price) {
this.price = price;
}
@Override
public ClassificationFinalized getClassification() {
return classification;
}
public void setClassification(final ClassificationFinalized classification) {
this.classification = classification;
}
public TechnicalData getTechnicalData() {
return technicalData;
}
public void setTechnicalData(final TechnicalData technicalData) {
this.technicalData = technicalData;
}
public Integer getSequenceCode() {
return sequenceCode;
}
public void setSequenceCode(final Integer sequenceCode) {
this.sequenceCode = sequenceCode;
}
@Override
public void setCompletedFlag() {
uncompleted = calculateCompleted() ? 0 : 1;
}
また、エンティティクラスとカートfindByRefVehicle(VehicleFinalized one)の実装を投稿してください。 – Zulfi
あなたの回答をありがとうZulfi、私は私のエンティティのコードを投稿しました –