derived

Subquery using derived table in Hibernate HQL

拈花ヽ惹草 提交于 2019-12-06 03:58:32
问题 I have a Hibernate HQL question. I'd like to write a subquery as a derived table (for performance reasons). Is it possible to do that in HQL? Example: FROM Customer WHERE country.id in (SELECT id FROM (SELECT id FROM Country where type='GREEN') derivedTable) (btw, this is just a sample query so don't give advice on rewriting it, is just the derived table concept I'm interested in) 回答1: Unfortunately no, derived tables don't currently work in HQL. For example, the following works: List<int>

access base class variable in derived class

狂风中的少年 提交于 2019-12-05 19:27:33
class Program { static void Main(string[] args) { baseClass obj = new baseClass(); obj.intF = 5; obj.intS = 4; child obj1 = new child(); Console.WriteLine(Convert.ToString(obj.addNo())); Console.WriteLine(Convert.ToString(obj1.add())); Console.ReadLine(); } } public class baseClass { public int intF = 0, intS = 0; public int addNo() { int intReturn = 0; intReturn = intF + intS; return intReturn; } } class child : baseClass { public int add() { int intReturn = 0; intReturn = base.intF * base.intS; return intReturn; } } I want to access intF and intS in child class whatever i input.. but i

Can I access a base classes protected members from a static function in a derived class?

时光总嘲笑我的痴心妄想 提交于 2019-12-05 10:07:19
问题 I have a program where I need to make a base class which is shared between a dll and some application code. Then I have two different derived classes, one in the dll one in the main application. Each of these have some static member functions which operate on the data in the nase class. (They need to be static as are used as function pointers elsewhere). In its simplest form my issue is shown below. class Base { protected: int var ; }; class Derived : public Base { static bool Process( Base

Base class vs Utility class

与世无争的帅哥 提交于 2019-12-05 04:38:30
Which of the two should be preferred? There are some methods which are called by class A, B and C. Should those methods be encapsulated in a class D (base of A, B and C) ? OR Should those methods be encapsulated in a class U and other classes creats it's object to use the methods as required. On what basis decision should be taken? Thanks. You should make a static utility class. Only use inheritance if it's actually meaningful—if A , B , and C actually are a D . I'd base the decision on what the methods are doing, if they're doing things specific to classes A, B and C then they should be in

Get address of base object from derived object

别等时光非礼了梦想. 提交于 2019-12-04 19:38:23
I'm getting a very confusing error in my program. I think I may have two different objects of the same class where I thought I had the same object. It is confusing because I am dealing with a very large framework where it is not simple to obtain a pointer to the object I need. My question is, if I have a class Derived which in inherits from Base, and I have a pointer to a Derived object, how can I get the address of the Base object from the derived object? I am working with the source code of the Base Class and am printing out the address of "this" in Base. In another part of my code a

Subquery using derived table in Hibernate HQL

冷暖自知 提交于 2019-12-04 08:16:21
I have a Hibernate HQL question. I'd like to write a subquery as a derived table (for performance reasons). Is it possible to do that in HQL? Example: FROM Customer WHERE country.id in (SELECT id FROM (SELECT id FROM Country where type='GREEN') derivedTable) (btw, this is just a sample query so don't give advice on rewriting it, is just the derived table concept I'm interested in) Unfortunately no, derived tables don't currently work in HQL. For example, the following works: List<int> result = nHSession.CreateQuery( @"select distinct Id from User u") .List<int>().ToList(); ...the following

Can I access a base classes protected members from a static function in a derived class?

我的梦境 提交于 2019-12-03 22:34:05
I have a program where I need to make a base class which is shared between a dll and some application code. Then I have two different derived classes, one in the dll one in the main application. Each of these have some static member functions which operate on the data in the nase class. (They need to be static as are used as function pointers elsewhere). In its simplest form my issue is shown below. class Base { protected: int var ; }; class Derived : public Base { static bool Process( Base *pBase ) { pBase->var = 2; return true; } }; My compiler complains that I cannot access protected

calling a template function of a derived class

穿精又带淫゛_ 提交于 2019-12-03 14:48:48
问题 I'm having a problem in C++ with calling a function of a derived class while having a pointer to the base class. EDIT: Some answers referred me to CRTP but my point is that I need to have a pointer to the "Base*" class not "Base*" because I'm unaware of the type currently being handled (The current instance is created from some sort of a factory). Classes: class Base { .. template<typename T> func (T arg) { ... }; }; class Derived1 : public Base { ... template<typename T> func (T arg) { ... }

Creating software derivative works from open source [closed]

倖福魔咒の 提交于 2019-12-03 14:44:15
Closed. This question is off-topic. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it's on-topic for Stack Overflow. This question has always been around my head. Can someone create a new product based on an existing open source project? Say you want to create an "Apaxe webserver" that is basically Apache with your some extra plugins ( say support for ASP or something similar ) Is this possible? Would you be able to create a closed source product ( either free or licensed ) As for GPL seems clear it is not possible because the source

calling a template function of a derived class

牧云@^-^@ 提交于 2019-12-03 03:44:18
I'm having a problem in C++ with calling a function of a derived class while having a pointer to the base class. EDIT: Some answers referred me to CRTP but my point is that I need to have a pointer to the "Base*" class not "Base*" because I'm unaware of the type currently being handled (The current instance is created from some sort of a factory). Classes: class Base { .. template<typename T> func (T arg) { ... }; }; class Derived1 : public Base { ... template<typename T> func (T arg) { ... }; }; class Derived1 : public Base { ... template<typename T> func (T arg) { ... }; }; Usage: int main()