Questions tagged [orm]

10701 questions
1

votes
1

answer
63

Views

Symfony/Doctrine2 and Associative entity

Usually when querying in a custom repository class, I use something like this : SELECT * FROM BundleName:Entity But how do I do for associative entity ? I have an entity 'Ticket' and an entity 'Tag'. It's a ManyToMany relation. In phpMyAdmin, I've got a ticket_tag associative table but how do I get...
Thibaut Tang
1

votes
1

answer
226

Views

ORM Who can generate script dynamically

So basically I was checking working of hibernate, as well evaluated ORMs JOOQ. JPA is main de-facto standard for all java based ORM implementations more or less. I am not saying they are not perfect or good but my problem is like I have found many issues and hick-ups while using various options prov...
1

votes
2

answer
32

Views

How to filter foreign key objects in django queries?

I have two models, one related to other by foreign key like this class CapturedPrescriptionModel(ColModel): p_id = models.IntegerField() p_age = models.IntegerField() p_gender = models.CharField(max_length=10) p_care_type = models.CharField(max_length=100) bacteria_id = models.ForeignKey(BacteriaLis...
sankycse
1

votes
1

answer
19

Views

Non-binary LIKE in MySQL through Django ORM

This is a follow-up from this question. Although I can write a non-binary LIKE query such as - SELECT COUNT(*) FROM TABLE WHERE MID LIKE 'TEXT%' in raw SQL, I would like to know if it's possible through the Django ORM. Both startswith and contains seem to be using a binary pattern search.
Sidharth Samant
1

votes
2

answer
31

Views

Eloquent build where query from array

So I'm trying to prepare an Eloquent query from data in an associative array: /* This works */ $this ->where('email', '[email protected]') ->where('is_active', 1) ->update($params); /* This doesn't work */ $where = [ 'email' => '[email protected]', 'is_active' => 1 ]; foreach ($where as $k => $v) { $this->whe...
Donal.Lynch.Msc
1

votes
1

answer
41

Views

How to pass two different arguments in a single function in django?

Python newbie here, I am trying to create a web-app where shippers can post their truck-loads on sale and accept bids from transporters, and the transporters can post their bids on loads. I have a list view function in my views.py, where a shipper can see all the bids posted by different suppliers,...
Rohit Kumar
0

votes
0

answer
7

Views

NPoco. Many to Many

I have two tables in my db and to c# models: public class Address { public int Id { get; set; } public string Name { get; set; } public string City { get; set; } } public class Customer { public int Id { get; set; } public string FirstName { get; set; } public string LastName { get; set; } } Als...
1

votes
0

answer
10

Views

How to group by and aggregate conditional in Django ORM

I have a Django query to get average hours worked per day per employee (There could be multiple worklogs per day). I want to split these up in weekday and weekend work. I have tried the following: qs = Worklog.objects.filter( day__range=[start,end] ).values( 'worker__fullname' ).annotate( weekday=Ca...
Matt
1

votes
2

answer
6k

Views

error: org.hibernate.PropertyNotFoundException: no appropriate constructor in class: com.a.offering.dto.SellerDetailsDto

I am using following query String queryString = 'select NEW com.h.offering.dto.SellerDetailsDto(p.productId,p.sellerId, p.sellerSku, p.sellPrice, ' + 'p.transferPrice, p.sellerMRP,p.aCommission,p.baseShippingFee,p.addnShippingFee, ' + 'p.propogationLevel,p.propogationValue,a.warehouseName,a.quantity...
Aashish Katta
0

votes
1

answer
14

Views

Why one thread can't not detect the changed value updated by the other thread? [duplicate]

This question already has an answer here: How to disable SQLAlchemy caching? 6 answers I am writing a program using SQLAlchemy, python, and multithreading. In my design, Thread A uses a while True loop. In each loop, it gets the queried object from database by SQLAlchemy, then check a field of the...
Cyan
0

votes
0

answer
5

Views

Grouping queryset by column value

I have a queryset that returns Tasks by client id from the following models and would like to get some more filters to receive more precised data. Models are just a example structure of what I am trying to achieve: class Client(models.Model): name = models.CharField(max_length=255) def __str__(self)...
tookas92
1

votes
1

answer
1.6k

Views

Laravel eager loading - relationship query

Say I have this 3 tables Blog, Post, Comment which has corresponding models Blog, Post, Comment. No here is the relation between them: Blog has many Post, posts() Post belongs to Blog, blog() Post has many Comment, comments() Comment belongs to Post post() Now I want to execute some query like...
vlio20
1

votes
1

answer
6.1k

Views

Composer/Doctrine 2 Class 'ComposerAutoloaderInit…' not found in vendor/autoload.php

This is driving me insane. Everything was moving along fine until I tried to change my composer.json file. Once I composer.update'ed I started getting this error in my log: PHP Fatal error: Class 'ComposerAutoloaderInite904d9fc0cad6e1b28066897f772cc3f' not found in /home/apache2/htdocs/doctrine/ven...
Ravioli87
1

votes
2

answer
274

Views

django prefetch_related & Prefetch nested

I'm trying to return, for each UserProfile, which has one-to-many Subscription, which has a Foreignkey to both Artist and UserProfile, with each artist having many ReleaseGroup, the count of future release groups that each UserProfile have. In short: I want to return the total count of upcoming rele...
zerohedge
1

votes
1

answer
141

Views

Swagger Invalid json message received

I'm using Symphony 4 with Doctrine and now I'm implementing / adding Swagger, so I will have proper docs where testing my api will be available. This is my postman, with proper inputed form data and OK response. And this are my 'problematic' notations of Swagger * @Route( * '/request', * na...
Valor_
1

votes
2

answer
31

Views

Django ORM - find objects that a variable fits inbetween a range of model fields?

I am trying to find all django objects using an integer variable, where this variable is inbetween two django model fields. I understand using __range() is normally for finding if a model field is inbetween two variables, but I need it the other way around. models: class Location(models.Model): loca...
trouselife
1

votes
1

answer
54

Views

Problem saving two models and retrieving a record from the database with Fluent

I'm just getting started with programming and vapor and have the following querying problem. When a user makes a request to /api/trip/new to create a new trip, I want to retrieve the first driver from the database and assign their ID to a Trip object. Then I want to save both the trip and trip reque...
marceli
1

votes
1

answer
33

Views

Find models that have only one particular related model

Consider the following models: class Product(models.Model): name = models.CharField(max_length=...) class Size(models.Model): name = models.CharField(max_length=...) products = models.ManyToManyField(Product, through=ProductXSize, related_name='sizes', related_query_name='size') class ProductXSize(m...
x-yuri
1

votes
1

answer
25

Views

How to compare counts in django ORM?

I have model like this: class A(models.Model): done = models.Boolean() And want to check if all done are True: A.objects.count() == A.objects.filter(done=True).count() But how to do the same thing inside DB in one query? ??? A.objects.annotate(Count('done??')).aggregate(??) ???
Aiven
1

votes
1

answer
50

Views

What is the usage of `FilteredRelation()` objects in Django ORM (Django 2.X)?

I've seen Django 2.0 consists of FilteredRelation object in queryset. What is the usage of newly introduced FilteredRelation? What I've looked into? I observed Django 2.0 Documentation but I could not understand idea behind this FilteredRelation object. I looked into following code. But I didn't get...
Devang Padhiyar
1

votes
3

answer
3.8k

Views

Better way to get the SUM of the field of an associated entity in Doctrine 2?

How can I get the sum of the fields of an associated entity? For example, Invoice and Bill has OneToMany and ManyToOne relationship respectively, that is an Invoice can have many Bills. The Bill entity has an Amount column. How can an Invoice get the SUM of its related Bills' Amount?
Jeboy
1

votes
0

answer
12

Views

Seeking advice on technologies to use for a project: ORMs, Building reactive interfaces, etc

My friend and I are starting a relatively ambitious long term project and we require some assistance deciding which technologies would be best suited for our needs. We would be very grateful for any advice or opinions on which technologies would be best suited for our project. Below is some informat...
zbbz
1

votes
0

answer
52

Views

Unsupported index types through migrations. Schema:update wants to remove some

I have a symfony 3.4.2 + doctrine 2.6 project using postgresql 9.6. I am trying to add some unsupported index types. I found this issue which points out that migrations should be used for this purpose. My problem is that the migrations work for 2 out of 3 indices. But doctrine:schema:update wants 3r...
Evren Yurtesen
1

votes
0

answer
359

Views

How can I use ORM database “Active Android” by Kotlin on Android Studio?

I try to use Active Android (ORM DataBase) in My Kotlin Project But when I save the EditText input , my program always crashes! All program codes are available in Gitlab.com Where is the problem with my codes? and if you know the sources of education in this regard, tell me to come MainActivity.kt ....
Majid ahmadi
1

votes
3

answer
720

Views

How to handle deadlock in Doctrine?

I have a mobile application and server based on Symfony which gives API for the mobile app. I have a situation, where users can like Post. When users like Post I add an entry in ManyToMany table that this particular user liked this particular Post (step 1). Then in Post table I increase likesCounter...
Tom
1

votes
1

answer
46

Views

Is it possible to combine fetch joins and COUNT in Doctrine?

I want to fetch join some entities to avoid a lot of additional queries and I also want to get count of related collection. Something like this: SELECT u, a, count(p) properties_count FROM User u JOIN u.address a LEFT JOIN u.properties p group by u.id That is I want to get a collection like [[0 =>...
AlexP11223
1

votes
0

answer
73

Views

Remove all related children in Symfony entity ManyToOne

That is my relations: in CategoryField Entity: manyToOne: category: targetEntity: Category inversedBy: fields joinColumn: name: category_id referencedColumnName: id in Category: oneToMany: fields: orderBy: { 'name': 'ASC' } targetEntity: CategoryField mappedBy: category cascade: ['remove'] I'm tryi...
alias
1

votes
1

answer
66

Views

Count occurrences of values on a single column grouped by week

I'm trying to accomplish this using Django 2.0 ORM, but if you can solve this with a raw SQL query that would be very helpful too. Say for example I have a table with the column 'destination', which will always be the name of a city, such as 'Los Angeles', 'New York', 'San Francisco', or 'Seattle' (...
Florence
1

votes
1

answer
75

Views

Query table columns by using 'desc tablename' command via PetaPoco

I want to get the columns info of a table in a Mysql database, and I use the micro-orm library PetaPoco. My code is as follows: var cols=db.Query('desc t_sometable').ToList(); But it throws an exception saying You have an error in your SQL syntax;check the manual that corresponds to your MySQL serv...
shine
1

votes
1

answer
377

Views

Django Rest Framework - automatically annotate queryset

I use one Serializer in many different places in my project. I need to use one annotation but the problem is that I don't want to annotate it in all views so I would like to do universal annotation in the Serializer itself. It is possible? Now I need to do this before every serialization: City.objec...
Milano
1

votes
1

answer
94

Views

HighCharts Render Annotated Queryset in Jinja2 Template

In my Jinja2 template I want to render a JavaScript array similar to this: [{ name: 'test', data: [ [Date.UTC(1970, 9, 29), 0], [Date.UTC(1970, 10, 9), 0.4], ... ] }, { name: 'Transport', data: [ [Date.UTC(1970, 10, 25), 0], ... ] }] I already managed to build a rather complex queryset in my Django...
Yannic Hamann
1

votes
2

answer
74

Views

Doctrine : SELECT a relationned entity

I have 2 entities : LinkServInfra Serv LinkServInfra entity : id serv (relation OneToOne to Serv) infra (ManyToOne to another entity) Now, I'd like to get a list of Serv based on infra. So I tried in LinkServInfraRepository : $qb = $this->createQueryBuilder('s') ->select('DISTINCT s.serv') ->wher...
Bastien Nicolau
1

votes
0

answer
132

Views

Hibernate OneToMany in MappedSuperclass fails with Null Constraint Violation

Based on Why does hibernate save two @OneToMany lists in one table? Imagine having following simplified code using Hibernate and JPA: @Entity class D { @Id @GeneratedValue public long id; } @MappedSuperclass abstract class A { @Id @GeneratedValue public long id; @OneToMany(cascade = CascadeType.ALL)...
Dracam
1

votes
1

answer
80

Views

Alternate preprocessing method to TypeDecorator in SQLAlchemy

I am using sqlalchemy.types.TypeDecorator to preprocess a text field before insertion into a database. It works great except when I am using the like expression with a comparator that contains percentages (e.g. User.name.like('%bar%')) because the percentages are stripped by the process_bind_param()...
slushy
1

votes
2

answer
37

Views

@ORM\OneToMany Is retrieving the virtual deleted entries

I have a relation in Doctrine2 @ORM\OneToMany, suposing that i have table school and student, in the entity school i have the @ORM\OneToMany column students, and i also have a virtual deletion column deleted_at, so every student that has the deleted_at different of null is a deleted student that is...
Albert Abdonor
1

votes
0

answer
390

Views

Android Sugar orm no such table

So like the title says my App crashes because I sugar orm can not create a new table. What I tried already: Disable Instant run Set version to 2 or higher Have an empty constructor Init the sugar context I use sugar orm version 1.5 My Code: (Manifest) My sugar orm Objects class import com.orm.SugarR...
Stein.
1

votes
2

answer
280

Views

Doctrine Class Table Inheritance can not remove() entity

I try to implement Doctrine's Class Table Inheritance. My Application needs a User Entity that is used to authenticate the user through Symfony's security system. On top of that, my application needs a special kind of User, a Doctor. Below you can find excerpts of my Entity classes. User class (Bas...
Momomentum
1

votes
0

answer
22

Views

How to access an entire table row based on annotation with Max()

I have a model that stores the cover images for different magazines (publications). In a simplified version it looks like this class Publication(models.Model): name = models.CharField(max_length=100) website = models.CharField(max_length=100) class PublicationIssue(models.Model): publication = model...
Philip B.
1

votes
1

answer
304

Views

Doctrine 2 Sementical Error couldn't find constant utilisateursadresses

I get this error [Semantical Error] Couldn't find constant utilisateursadresses, class Ecommerce\EcommerceBundle\Entity\Uti lisateursAdresses whene i try php app/console doctrine:generate:entities EcommerceBundle:UtilisateursAdresses my code : namespace Ecommerce\EcommerceBundle\Entity; use Doct...
Yassine Bayoudh
1

votes
1

answer
215

Views

Doctrine Fixtures Bundle wont install on Symfony 2.4.10

I am currently using symfony 2.4.10 i wanted to install Doctrine Fixtures Bundle but when i use composer require --dev doctrine/doctrine-fixtures-bundle to install it i get this : Your requirements could not be resolved to an installable set of packages. Problem 1 - symfony/doctrine-bridge v4.0.3 re...
Yassine Bayoudh

View additional questions