I'm writing an application that is used to catalog files, and attribute those files with meta data. A photo album program would be a good comparison to what I'm trying to do.
I'm trying to abstract the interface between my program and the file system which stores the files, and the database which stores the meta data for the files. This...
I am trying to create an application in java which pulls out records from the database and maps it to objects. It does that without knowing what the schema of the database looks like. All i want to do is fetch all rows from all tables and store them somewhere. There could be a thousand tables with thousands of records each. The applicati...
I am trying building a simple project from scratch using Rails 3. Usually, the models are like:
class Student < ActiveRecord::Base
has_many :awards
end
class Award < ActiveRecord::Base
belongs_to :student
end
and we use the award.id and student.id to get the corresponding records.
But what if it is
class Company < ActiveRecord...
Hi I have a problem fetching the skills from the volunteer. for some reason i dont get the list when using this method
public Volunteer getVolunteer(int id){
Volunteer vo;
Query q;
q = em.createNamedQuery("Volunteer.findById").setParameter("id", id);
vo = (Volunteer) q.getSingleResult();
for(Skill s: vo.getSkills()){
System.o...
Hi, I write this post to know if someone knows how to do this:
I want to do this insert:
INSERT INTO TABLA (CAMPO1, CAMPO2) VALUES (?, crypt(?,'cdp'))
Crypt is a funtion stored in my database and the insert I would want to do it in my code. Actually when I want to insert something in the database I use:
getHibernateTemplate().persis...
Is there a way to tell hibernate's hbm2ddl to not create specific table but still have the model be recognized by Hibernate.
The thing is that the model map to a view and I want to have an in-memory database (empty on startup and deleted on termination) for testing, hence, having 2 sets of mapping is out of the question.
...
@Entity
public class Person {
@ElementCollection
private List<Location> locations;
[...]
}
@Embeddable
public class Location {
private Integer dummy;
private Date creationDate;
[...]
}
Given the following structure, I'd like to perform the HQL or CriteriaQu...
Hi i am trying to execute this simple HQL query to get a list of files from my database using:
private static final String SQL_GET_FILE_LIST = "select filename, size, id, type from fileobject";
@Override
public List<FileObject> getFileList(String type) {
// TODO Auto-generated method stub
List<FileObject> files = hbTemplate.fin...
Hi all,
I wanted to know if there is a way to get in a One2Many relationship a field of the One side that is an aggregate of the Many side.
Let's take the following example:
@Entity
public class A {
@Id
private Long id;
@OneToMany (mappedBy="parentA")
private Collection<B> allBs;
// Here I don't know how to Map the latest B by d...
Hi i am developing a spring mvc app thats using hibernate to connect to a mysql database that stores files.
I have two methods. one that adds all files from a specific file path of my choosing and another method that invokes a query to return me a list of the files stored from mysql.
The issue is this. When i execute the first method o...
I'm working on a application that needs to do some database operations.
I created a static variable for EntityManagerFactory and Intialized it in the method that gets called by the application
if (emf == null){
emf = Persistence.createEntityManagerFactory("example");
}
try {
em = emf.cr...
Hello,
I saw few examples over internet of Hibernate using transaction.commit() for select statements. Below is the example code.
public static List<?> list(Class<?> className,int start,int limit,SearchFilter[] searchFilter){
Session session = HibernateUtil.getSessionFactory().openSession();
Transaction transaction = null;
...
@Entity
public class MUser implements Serializable, MemoEntity {
private static final long serialVersionUID = 1L;
@Id
private String email;
@OneToMany(cascade=CascadeType.ALL, orphanRemoval=true)
private Set<Meaning> mengs = new HashSet<Meaning>();
Shouldn't this mean that I get the constraint with a "on delete cascade"?
This is wha...
I've been dealing with composite id's and asked a few questions and I was recommended to replace my composite PK's with a single id column, and to control integrity with indexes... All of this related to the fact that mapping composite id's isn't that simple...
On the other side, some people encourage the usage of composite id's that a...
I've JPA entities and need to perform logic with them. Until now a huge static database class did the job. It's ugly because every public interface method had an private equivalent that used the EntityManager, to perform transactions. But I could solve that having a static em too!
However i'm wondering if that's an appropriate design, es...
Is there a way for me to find out which Classes (i.e instance of which different types ) are cached in hibernate second level cache.
...
I'm creating an application that has to work with different databases (Oracle, MSSQL, MySQL...) through JDBC. I have to work via JDBC because my application calls stored procedures in these databases.
What is the best aproach for building such applications? Are there any frameworks for this?
Important: The solution must nicely deal wit...
Hi,
I'm sligthly confused as to how the cascade="delete" works. I defined the mapping in the following way in the City mapping file:
<set inverse="true" name="client" cascade="delete">
<key>
<column name="id_name"/>
</key>
<one-to-many class="model.Client"/>
</set>
The class Client has a foreign key to a class City.
So w...
Hello everybody.
I have a task to attach Oracle Coherence (it is cache software) in my project. One way of using it is Level2 Hibernate cache.
I want to see when hibernate takes results from L2 cache. How can i do that? Both ways will be good: listener of some sort, if possible, or direct access to Cache object.
Thanks in advance.
...
Suppose I have a class 'Cheese' with fields type and purchaseDate, such that:
public class Cheese{
CheeseType cheeseType;
String purchaseDate;
public setPurchaseDate(String value){
purchaseDate=value;
}
public Class CheeseType{
String type;
public setType(String value){
type=value;
...