Hey Everyone,
I'm having this problem while writing my own HashTable. It all works, but when I try to templatize the thing, it gave me errors. I recreated the problem as follows:
THIS CODE WORKS:
typedef double Item;
class A
{
public:
A()
{
v.push_back(pair<string, Item>("hey", 5.0));
}
void iterate()
{
for(Iterator iter = v.begin(); iter != v.end(); ++iter)
cout << iter->first << ", " << iter->second << endl;
}
private:
vector<pair<string, double> > v;
typedef vector< pair<string, double> >::iterator Iterator;
};
THIS CODE DOES NOT:
template<typename ValueType>
class B
{
public:
B(){}
void iterate()
{
for(Iterator iter = v.begin(); iter != v.end(); ++iter)
cout << iter->first << ", " << iter->second << endl;
}
private:
vector<pair<string, ValueType> > v;
typedef vector< pair<string, ValueType> >::iterator Iterator;
};
the error messages:
g++ -O0 -g3 -Wall -c -fmessage-length=0 -omain.o ..\main.cpp
..\main.cpp:50: error: type std::vector<std::pair<std::string, ValueType>, std::allocator<std::pair<std::string, ValueType> > >' is not derived from typeB'
..\main.cpp:50: error: ISO C++ forbids declaration of `iterator' with no type
..\main.cpp:50: error: expected `;' before "Iterator"
..\main.cpp: In member function `void B::iterate()':
..\main.cpp:44: error: `Iterator' was not declared in this scope
..\main.cpp:44: error: expected `;' before "iter"
..\main.cpp:44: error: `iter' was not declared in this scope
Does anybody know why this is happening? Thanks!
I would like to delete the ICollection PriceBreaks from Product.
I'm using the following method. However they dont seem to delete. What am i missing.
When i step thru. i notice that "product.PriceBreaks.Clear();" doesn't actually clear the items. Do i need to flush or something?
public void RemovePriceBreak(int productId)
{
using (ISession session = EStore.Domain.Helpers.NHibernateHelper.OpenSession())
using (ITransaction transaction = session.BeginTransaction())
{
var product = session.Get<Product>(productId);
product.PriceBreaks.Clear();
session.SaveOrUpdate(product);
transaction.Commit();
}
}
Here are my hbm files
<class name="Product" table="Products">
<id name="Id" type="Int32" column="Id" unsaved-value="0">
<generator class="identity"/>
</id>
<property name="CompanyId" column="CompanyId" type="Int32" not-null="true" />
<property name="Name" column="Name"/>
<set name="PriceBreaks" table="PriceBreaks" generic="true" cascade="all-delete-orphan" inverse="true" >
<key column="ProductId" />
<one-to-many class="EStore.Domain.Model.PriceBreak, EStore.Domain" />
</set>
</class>
<class name="PriceBreak" table="PriceBreaks">
<id name="Id" type="Int32" column="Id" unsaved-value="0">
<generator class="identity"/>
</id>
<many-to-one name="Product" column="ProductId" not-null="true" cascade="all" class="EStore.Domain.Model.Product, EStore.Domain" />
</class>
My Entities
public class Product
{
public virtual int Id { get; set; }
public virtual ICollection<PriceBreak> PriceBreaks { get; set; }
public virtual void AddPriceBreak(PriceBreak priceBreak)
{
priceBreak.Product = this;
PriceBreaks.Add(priceBreak);
}
}
public class PriceBreak
{
public virtual int Id { get; set; }
public virtual Product Product { get; set; }
}
I have the following table...
TABLE: Accounts
ID (int, PK, Identity)
AccountType (int, PK)
Username (varchar)
Password (varchar)
I have created a composite key out of ID and AccountType columns so that people can have the same username/password but different AccountTypes.
Does this mean that for each foreign table that I try and link to I'll have to create two columns?
I’m using SQL Server 2008
I have a UserControl in which a FlowLayoutPanel.
This user control consist of a description and some controls:
[descr.] 123456789, it should be able to be reversed 987654321 [descr.]
So FlowLayoutPanel is used for this scope(RightToLeft - True/False).
Is this a way that the label1 fill the rest of the control(to left or right respectively)?
Hi,
I have this sql statement SELECT * FROM Language WHERE LanguageCode=? where LanguageCode is a varchar(2).
When I use sqlite3-prepare-v2 on that statement I got SQLITE_ERROR but if I use SELECT * FROM Language WHERE LanguageID=? where LanguageID is the primary key numeric identity field the statement compiles just fine.
Is there any issue filtering by a varchar field using WHERE statement?
Thanks
I am reading the Asp.net security documentation on msdn.I come across these tow terms and get really confused.
# WindowsIdentity = WindowsIdentity.GetCurrent(),
which returns the identity of the security context of the currently executing Win32 thread.
# Thread = Thread.CurrentPrincipal
which returns the principal of the currently executing .NET thread which rides on top of the Win32 thread.
I have taken the idea of "language maintenance" a niche that no one is paying attention to and created a company focused on live conversation with complimentary tools. Looking to create a web 2.0 style social network with an already clearly defined brand identity, design and plan. Already have assembled a team but am looking for a passionate programmer to take the technical lead and create a functional alpha and beta.
Having a class like this:
class Spam(object):
def __init__(self, name=''):
self.name = name
eggs = Spam('systempuntoout')
using dis, is it possible to see how an instance of a class and the respective hex Identity are created?
my file is:
[plugin:form]
use = repoze.who.plugins.form:make_redirecting_plugin
login_form_url = /account/signin
login_handler_path = /account/login
logout_handler_path = /account/logout
[identifiers]
plugins =
form;browser
auth_tkt
i created a form on /account/signin, but it doesnt find the identity? what has to be on the form?
What i did:
create a project,
edited the ui file with the designer tool,
ran the project, everything is ok
tried to add to my cppfile:
connect( pushButton_bracketBegin, SIGNAL( clicked() ), this, SLOT( pushButton_bracketBeginAction() ) );
but i get the error "‘pushButton_bracketBegin’ was not declared in this scope". this is my first project in qt and it should be fairly simple i guess (but yet out of my grasp ) :) appreciate the help
I have 2 records in a table in SQL Server 2005 db which has exactly same data.
I want to update one record.Is there anyway to do it?Unfortunately this table does not have an identity column and i cant use a direct update query because both will be updated since data is same.Is there anyway using rowid or something in SQL server 2005 ?
I need to develop a geometry library in python, describing points, lines and planes in 3d space, and various geometry operations. Related to my previous question.
The main issue in the design is if these entities should have identity or not. I was wondering if there's a similar library out there (developed in another language) to take inspiration from, what is the chosen design, and in particular the reason for one choice vs. the other.
What is the memory and performance usage compared to creating a object with only a constructor?
The usage here is in creating a Set<Object> or List<Object> that may contain million plus entries and I am concerned with the overhead of using Bloch's Builder Pattern. I have used it in the past, but never in this large of a scope.
In .net when a website hosted in IIS how do you get the current user the website is running under. ie the Application Pool user not the the current user accessing the site.
Using windows integrated and impersonate.
<authentication mode="Windows"/>
<identity impersonate="true"/>
Say I am using an Identity Matrix for my modelViewTransformation Matrix on an Open GL ES2.0 program. The Co-ordinate system in this case is the canonical opengl co-ordinate system which extends from (-1,-1,-1) to (1,,1,1).
My question is, is this coordinate system right-handed or left-handed?
A broader question: Is there a document with OpenGL which can list all the mathematical conventions followed by the API?
Hi,
I guess starting a timer job from within the code required Farm admin credetials. However, i need to start a timer job from a web part that will be used in any site. Now when i try to start the job it gives me access denied error and obviously so as app pool identity is not farm admin. Any ideas on how to resolve this issue?
Thanks,
I've found many definitions of the 'var' statement but most of them are incomplete (usually from introductory guides/tutorials). Should I use 'var' if the variable & scope has been declared in the params list?
someFunc = function(someVar)
{
// Is it considered good practice to use 'var', even if it is redundant?
var someVar = cheese;
};
I have a Class A:
public class ClassA
{
public int ID {get; private set;}
public string Code {get; private set;}
public ClassB B {get; private set;}
public IList<ClassB> ListB {get; private set;}
}
And a ClassB:
public class ClassB
{
public int ID {get; private set;}
public string Code {get; private set;}
public ClassA A {get; private set;}
//some other attributes...
}
And the Mappings:
public ClassAMap()
{
Table("ClassA");
Id(classA => classA .ID, "ID").GeneratedBy.Identity();
Map(classA => classA.Code, "Code").Unique().Not.Nullable();
//HERE IS THE PROBLEM: --------
References(classA => classA.B,"IDClassB").Cascade.SaveUpdate();
//-----
HasMany(classA => classA.ListB).Table("ClassB").KeyColumn("IDClassA").AsBag().Not.LazyLoad().Inverse().Cascade.AllDeleteOrphan();
}
ClassB Mappings:
public ClassBMap()
{
Table("ClassB");
Id(classB => classB.ID).GeneratedBy.Identity();
References(classB => classB.A, "IDClassA").ForeignKey("ID").Cascade.SaveUpdate();
}
The mappings for ListB in classA worked ok, because at first the was only ListB property and not B, when i had to map B i tried this:
References(classA => classA.B,"IDClassB");
The mapping test failed because B wasn't saved, so i did this:
References(classA => classA.B,"IDClassB").Cascade.SaveUpdate();
This time B was saved, but by saving B, classA was inserted two times, by A.B and by B.A.
How can i solve this problem? Why does it work for the ListB property and not for the B property? Thanks
Hi All,
i am reading spring through its official documentation and at one place i came to a line that use prototype scope for for all statefull beans while singleton for stateless beans.
i know there is something as statefull as well stateless beans in EJB but this is not what they have mentioned in the documents.
Can any one explain me what exact this means of statefull as well stateless beans in Spring
Thanks in advance
Hello,
I am returning the variable I am creating in a using statement inside the using statement (sounds funny):
public DataTable foo ()
{
using (DataTable properties = new DataTable())
{
// do something
return properties;
}
}
Will this Dispose the properties variable??
After doing this am still getting this Warning:
Warning 34 CA2000 : Microsoft.Reliability : In method 'test.test', call System.IDisposable.Dispose on object 'properties' before all references to it are out of scope.
Any Ideas?
Thanks
Hi all;
var v_name = null;
$.ajax({
type: "GET",
url: "Testpage.aspx",
data: "name=test",
dataType: "html",
success: function(mydata) {
v_name= mydata;
}
});
alert(v_name);
Output: alert in null
"success" scope in alert work
how to make ? pls help
I would love to thank @Stefan Steinegger and @David helped me out yesterday with many-to-many mapping.
I have 3 tables which are "News", "Tags" and "News_Tags" with Many-To-Many relationship and the "News_Tags" is the link table.
If I delete one of the news records, the following mappings will delete all my news records which have the same tags. One thing I need to notice, I only allowed unique tag stored in the "Tag" table.
This mapping make sense for me, it will delete the tag and related News records, but how can I implement a tagging system with NHibernate?
Can anyone give me some suggestion? Many thanks.
Daoming.
News Mapping:
<class name="New" table="News" lazy="false">
<id name="NewID">
<generator class="identity" />
</id>
<property name="Title" type="String"></property>
<property name="Description" type="String"></property>
<set name="TagsList" table="New_Tags" lazy="false" inverse="true" cascade="all">
<key column="NewID" />
<many-to-many class="Tag" column="TagID" />
</set>
</class>
Tag Mapping:
<class name="Tag" table="Tags" lazy="false">
<id name="TagID">
<generator class="identity" />
</id>
<property name="TagName" type="String"></property>
<property name="DateCreated" type="DateTime"></property>
<!--inverse="true" has been defined in the "News mapping"-->
<set name="NewsList" table="New_Tags" lazy="false" cascade="all">
<key column="TagID" />
<many-to-many class="New" column="NewID" />
</set>
</class>
This shows how to have a static variable inside an object or context:
http://www.mail-archive.com/[email protected]/msg04764.html
But the scope is too large for some needs, is it possible to have a static variable inside an object function ?