T
tomo
Let's say I have Person entity which has Company entity(FK). And I have a
function that takes company type as an argument.Is it better to use
public void persistEntity(Short type){
Company company = new Company();
company.setType((short)1);
Person person = new Person();
person.setCompany(company);
entityManager.persist(person);
}
or
public void persistEntity(Short type){
Company company = entityManager.find(1,Company.class);
Person person = new Person();
person.setCompany(company);
entityManager.persist(person);
}
I have noticed that they do the same, but the first one is much
faster.Thanks.
public class Person{
private Long id;
private Company company;
private String name;
}
public class Company{
private Short type;
private String name;
}
__________ Information from ESET NOD32 Antivirus, version of virus signature database 5171 (20100604) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
function that takes company type as an argument.Is it better to use
public void persistEntity(Short type){
Company company = new Company();
company.setType((short)1);
Person person = new Person();
person.setCompany(company);
entityManager.persist(person);
}
or
public void persistEntity(Short type){
Company company = entityManager.find(1,Company.class);
Person person = new Person();
person.setCompany(company);
entityManager.persist(person);
}
I have noticed that they do the same, but the first one is much
faster.Thanks.
public class Person{
private Long id;
private Company company;
private String name;
}
public class Company{
private Short type;
private String name;
}
__________ Information from ESET NOD32 Antivirus, version of virus signature database 5171 (20100604) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com