hi,
MyTable is a table in my Oracle DB, it has a CMP_ID to join the COMPANIES table.
Here is the Java implementation :
public class MyTable implements Serializable {
...
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumns( { @JoinColumn(name = "CMP_ID", referencedColumnName = "CMP_ID", nullable = false) })
@XmlTransient
Company company;
....
If i use ex.merge(obj), now if in object obj i set the primary key to a value which is not present in database, will it create a new record or will it throw an exception?
for example
if obj with pk val = 19 doesnot exist in database,and i set
obj.setPk(20);
obj.setName("nm");
em.merge(obj) // will this throw an exception or create a ...
The object structure is like below-
Entity A
- Collection <B>
Entity B
- Collection <C>
Entity C
-Collection <D>
Entity D
CompositePrimaryKey
Class CompositePrimaryKey
String id;
In the HQL, the query is like from A a where a.B.C.D.CompositePrimaryKey.id = 'input';
I am getting the below exception-
org.hibernate.QueryE...
I am converting a web project that currently uses the Propel ORM, to a django project.
My first task is to 'port' the model schema to django's.
I have read the django docs, but they do not appear to be in enough detail. Case in point, how may I 'port' a (contrived) table defined in the Propel YML schema as follows:
demo_ref_country:...
I'm using Kohana's ORM library, and I'm wondering if there is any way to order the results that are generated.
Example:
$priorities = ORM::factory('priority')->select_list('id','label'); //how to order these?
...
Hi I need to do something like this:
$hours->task->job->where('group_id' , '=' , $num)->find_all();
This would return job information. Is there any way to tell orm to return the information from the $hours table instead?
...
I use Hibernate with annotations. I need to insert object into the database using a method who needs one parameter that I need to calculate, to do this I use:
SQLQuery sqlQuery = getSession().createSQLQuery(queryString);
sqlQuery.executeUpdate();
The queryString contains:
INSERT INTO TABLE(ID, NUMBER) VALUES (SEC_TABLE.NEXTVAL, 549)
...
Hi all,
My google-fu is failing me in this. I'm doing a small database app which reads some data from a file along with some meta data that I currently store in a Map in my entity. I'm getting fed up with it always being displayed in a random order.
So can I use a LinkedHashMap or @OrderColumn with Maps somehow to preserve insertion or...
Consider the case where a CHAR field primary_key is required in order to define a ForeignKey relationship.
After some initial investigation I have identified the following possibilities, each with their own drawbacks:
1) Using 'primary_key=True'.
Example 1:
class Collection(models.Model):
code = models.CharField(primary_key=True,...
When using Kohana 3's ORM models, what is the best way to get data from fields of related models? For example, I have an employee, who has one company, and has many assignments. How would I go about getting data from fields in the company model and assignment model(s) (i.e. in a has_one and a has_many relationship)?
EDIT: as requested, ...
I'm trying to remove relationships from a pivot table with ORM's remove method. This is for an edit method that updates the categories associated with a product. I can successfully add multiple relationships, but I need to remove those relationships prior to adding them again.
Here's how I add them
foreach ($categories as $a...
The requirement is that the user can write an article, therefore I choose type Text for the content field inside mysql database. How can I convert Java String into MySQL Text
Here you go Jim Tough
@Entity
public class Article implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(stra...
Database: MySql 5.1.47 on OS X
ORM Settings in Application.cfc:
this.ormEnabled = true;
this.ormsettings = {
autogenmap = true,
dbCreate = application.dbCreate,
automanageSession = true,
datasource = application.dsn,
logSQL = application.logSQL,
sqlScript = application.sqlScript
};
News.cfc
/**
* These are the news item...
I was thinking of this the other day, apps like Twitter deal with millions of users. I was thinking how the functionality of 'following' would work, where the maximum amount of users in the database can follow the maximum amount of users in the database less one, (himself).
If this was a ManyToMany bidirectional mapping, it would cre...
I've been a heavy user of .Net since its inception, but I have avoided using any of its ORM features, regardless of flavor. I have always been skeptical of tools which abstract CRUD, binding, validation, searching, etc. Some of this skepticism comes from painful, real-world experience; the rest of it comes from the innate desire to "own"...
The following:
I have approximantely 20 models. These classes extend a base class. This base class contains a method which should be able to determine the classname of the child element. Normally you could this with:
get_called_class();
But in many cases doctrine 2 uses ProxyClasses and in that case the get_called_class() function re...
Hello !
I have a query builded with EntityManager:
Query q = em
.createQuery("SELECT * FROM :table WHERE username = :username AND password = MD5(:password)")
.setParameter("table", User.class.getName())
.setParameter("username", txtLogin.getText())
.setParameter("password", passPassword.getPassword())
;
User user = (Us...
I'm following the fairly standard L2S repository pattern, using the following as one of the methods
public IEnumerable<T> GetAllByFilter(Func<T, bool> expression)
{
return _dataContext.GetTable<T>().Where(expression);
}
I'm a bit miffed to see that the call to GetTable appears to literally get the table, with the Where expressi...
Hey all,
I'm reviewing the IntelliJ ability related to JPA ER Diagrams (http://www.jetbrains.com/idea/features/jpa_hibernate.html), and is something I've been looking for a while.
Does anyone know of other tools that have similar abilities, whether as standalone, eclipse plugin, or other alternatives with the intent that the Graphical T...
Summary: the Exception is telling me that the transaction is read-only; a debug println seems to indicate that I'm not in read-only mode.
Classes edited for internet publishing - sorry if I mistyped something but this is the jist of the code giving me problems. saveOrUpdate works when called on other object types but not on this one. ...